Skip to content

Instantly share code, notes, and snippets.

@yosoufe
Last active March 7, 2020 21:48
Show Gist options
  • Save yosoufe/8bfc452d06a9d0118133957a8f5e5f1e to your computer and use it in GitHub Desktop.
Save yosoufe/8bfc452d06a9d0118133957a8f5e5f1e to your computer and use it in GitHub Desktop.
Commands needed to manage the pulseAudio
# list all the devices 
aplay -l

it generates such an output for me which is missing the bluetooth devices

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1220 Analog [ALC1220 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1220 Digital [ALC1220 Digital]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Now if I need to load a sink profile on HDMI 0 and 3 because I have monitors with speakers connected to those I would use the following command

pacmd load-module module-alsa-sink device="hw:2,3" sink_name=lg_monitor
pacmd load-module module-alsa-sink device="hw:2,9" sink_name=msi_monitor

which in device="hw:2,9" the first number is the card # number and the second is device # in the output of aplay -l.

If I want to create a synched output streaming to both monitors:

pacmd load-module module-combine-sink sink_name=all_monitors slaves=msi_monitor,lg_monitor

If you want to have them as default you may copy the aboce pacmd commands (excpet the pacmd word itself) into /etc/pulse/default.pa like

unload-module module-alsa-sink device="hw:2,3" sink_name=msi_monitor
unload-module module-alsa-sink device="hw:2,9" sink_name=lg_monitor
load-module module-combine-sink sink_name=all_monitors slaves=msi_monitor,lg_monitor
set-default-sink msi_monitor

To unload the them, you need to index numbers, You can get them from pactl list sinks or pacmd list sinks and use pacmd unload-module <index number> to unload it.

In my bashrc I would define

SoundSetup()
{
    pacmd load-module module-alsa-sink device="hw:2,3" sink_name=lg_monitor
    pacmd load-module module-alsa-sink device="hw:2,9" sink_name=msi_monitor

    pacmd update-sink-proplist lg_monitor device.description=lg_monitor
    pacmd update-sink-proplist msi_monitor device.description=msi_monitor

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment