Module pulseaudio_dbus

Control audio devices using the pulseaudio DBus interface.

For this to work, you need the line load-module module-dbus-protocol in /etc/pulse/default.pa or ~/.config/pulse/default.pa

Usage:

    pulse = require("pulseaudio_dbus")
    address = pulse.get_address()
    connection = pulse.get_connection(address)
    core = pulse.get_core(connection)
    sink = pulse.get_device(connection, core:get_sinks()[1])
    sink:set_muted(true)
    sink:toggle_muted()
    assert(not sink:is_muted())
    sink:set_volume_percent({75}) -- sets the volume to 75%
    

Info:

  • Copyright: 2017-2020 Stefano Mazzucco and contributors
  • License: Apache License, version 2.0
  • Author: Stefano Mazzucco

Functions

pulse.get_address () Get the pulseaudio DBus address
pulse.get_connection (address[, dont_assert]) Get a connection to the pulseaudio server

Class Core

pulse.Core:get_sinks () Get all currently available sinks.
pulse.Core:get_cards () Get all currently available cards.
pulse.Core:get_sources () Get all currently available sources.
pulse.Core:get_fallback_sink () Get the current fallback sink object path
pulse.Core:set_fallback_sink (value) Set the current fallback sink object path
pulse.Core:get_fallback_source () Get the current fallback source object path
pulse.Core:set_fallback_source (value) Set the current fallback source object path
pulse.get_core (connection) Get the pulseaudio core object

Class Stream

pulse.get_stream (connection) Get the pulseaudio Stream

Class Device

pulse.Device:get_state () Get the current state of the device.
pulse.Device:get_volume () Get the volume of the device.
pulse.Device:get_volume_percent () Get the volume of the device as a percentage.
pulse.Device:set_volume (value) Set the volume of the device on each channel.
pulse.Device:set_volume_percent (value) Set the volume of the device as a percentage on each channel.
pulse.Device:volume_up () Step up the volume (percentage) by an amount equal to self.volume_step.
pulse.Device:volume_down () Step down the volume (percentage) by an amount equal to self.volume_step.
pulse.Device:is_muted () Get whether the device is muted.
pulse.Device:set_muted (value) Set the muted state of the device.
pulse.Device:toggle_muted () Toggle the muted state of the device.
pulse.Device:get_active_port () Get the current active port object path
pulse.Device:set_active_port (value) Set the active port object path
pulse.get_device (connection, path[, volume_step[, volume_max]]) Get an DBus proxy object to a pulseaudio Device.

Class Port

pulse.get_port (connection, path) Get the pulseaudio DevicePort


Functions

pulse.get_address ()
Get the pulseaudio DBus address

Returns:

    a string representing the pulseaudio DBus address.
pulse.get_connection (address[, dont_assert])
Get a connection to the pulseaudio server

Parameters:

  • address string DBus address
  • dont_assert boolean whether we should not assert that the connection is closed. (optional)

Returns:

    an lgi.Gio.DBusConnection to the pulseaudio server

See also:

Class Core

pulse.Core:get_sinks ()
Get all currently available sinks. Note the the Sinks property may not be up-to-date.

Returns:

    array of all available object path sinks
pulse.Core:get_cards ()
Get all currently available cards. Note the the Cards property may not be up-to-date.

Returns:

    array of all available object path cards
pulse.Core:get_sources ()
Get all currently available sources. Note the the Sources property may not be up-to-date.

Returns:

    array of all available object path sources
pulse.Core:get_fallback_sink ()
Get the current fallback sink object path

Returns:

  1. fallback sink object path (may not be up-to-date)
  2. nil if no falback sink is set

See also:

pulse.Core:set_fallback_sink (value)
Set the current fallback sink object path

Parameters:

  • value string fallback sink object path

See also:

pulse.Core:get_fallback_source ()
Get the current fallback source object path

Returns:

  1. fallback source object path
  2. nil if no fallback source is set

See also:

pulse.Core:set_fallback_source (value)
Set the current fallback source object path

Parameters:

  • value string fallback source object path

See also:

pulse.get_core (connection)
Get the pulseaudio core object

Parameters:

  • connection lgi.Gio.DBusConnection DBus connection to the pulseaudio server

Returns:

    the pulseaudio core object that allows you to access the various sound devices

Class Stream

Pulseaudio Stream Use pulse.get_stream to obtain a stream object.
pulse.get_stream (connection)
Get the pulseaudio Stream

Parameters:

  • connection lgi.Gio.DBusConnection DBus connection to the pulseaudio server

Returns:

    A new Stream object

Class Device

Pulseaudio Device.
Use pulse.get_device to obtain a device object.
pulse.Device:get_state ()

Get the current state of the device. This can be one of:

  • "running": the device is being used by at least one non-corked stream.
  • "idle": the device is active, but no non-corked streams are connected to it.
  • "suspended": the device is not in use and may be currently closed.

Returns:

    the device state as a string
pulse.Device:get_volume ()
Get the volume of the device. You could also use the Device.Volume field, but it's not guaranteed to be in sync with the actual changes.

Returns:

    the volume of the device as an array of numbers (one number) per channel

See also:

pulse.Device:get_volume_percent ()
Get the volume of the device as a percentage.

Returns:

    the volume of the device as an array of numbers (one number) per channel

See also:

pulse.Device:set_volume (value)
Set the volume of the device on each channel. You could also use the Device.Volume field, but it's not guaranteed to be in sync with the actual changes.

Parameters:

  • value table an array with the value of the volume. If the array contains only one element, its value will be set for all channels.

See also:

pulse.Device:set_volume_percent (value)
Set the volume of the device as a percentage on each channel.

Parameters:

  • value table an array with the value of the volume. If the array contains only one element, its value will be set for all channels.

See also:

pulse.Device:volume_up ()
Step up the volume (percentage) by an amount equal to self.volume_step. Calling this function will never set the volume above self.volume_max

See also:

pulse.Device:volume_down ()
Step down the volume (percentage) by an amount equal to self.volume_step. Calling this function will never set the volume below zero (which is, by the way, an error).

See also:

pulse.Device:is_muted ()
Get whether the device is muted.

Returns:

    a boolean value that indicates whether the device is muted.

See also:

pulse.Device:set_muted (value)
Set the muted state of the device.

Parameters:

  • value boolean whether the device should be muted You could also use the Device.Mute field, but it's not guaranteed to be in sync with the actual changes.

See also:

pulse.Device:toggle_muted ()
Toggle the muted state of the device.

Returns:

    a boolean value that indicates whether the device is muted.

See also:

pulse.Device:get_active_port ()
Get the current active port object path

Returns:

  1. the active port object path, if it exists.
  2. pair nil, userdata, if the device doesn't have any ports. Where the userdata is NoSuchPropertyError.

See also:

pulse.Device:set_active_port (value)
Set the active port object path

Parameters:

  • value string port object path

Raises:

assertion error if trying to set an invalid port.

See also:

pulse.get_device (connection, path[, volume_step[, volume_max]])
Get an DBus proxy object to a pulseaudio Device.
Setting a property will be reflected on the pulseaudio device. Trying to set other properties will result in an error.

Parameters:

  • connection lgi.Gio.DBusConnection The connection to pulseaudio
  • path string The device object path as a string
  • volume_step number The volume step in % (defaults to 5) (optional)
  • volume_max number The maximum volume in % (defaults to 150) (optional)

Returns:

    A new Device object

See also:

Usage:

    -- get a pulseaudio sink (e.g. audio output)
    sink = pulse.get_device(connection, core:get_sinks()[1])
    -- get a pulseaudio source (e.g. microphone)
    source = pulse.get_device(connection, core:get_sources([1]))

Class Port

Pulseaudio DevicePort.
Use pulse.get_port to obtain a port object.
pulse.get_port (connection, path)
Get the pulseaudio DevicePort

Parameters:

  • connection lgi.Gio.DBusConnection DBus connection to the pulseaudio server
  • path string The port object path as a string

Returns:

    A new DevicePort object
generated by LDoc 1.4.6 Last updated 1980-01-01 00:00:00