Is there a way to change output audio devices on the fly?
I want to achive the same effect of going to the System Tray, click audio icon and select device.
I tried with pacmd set-default-sink index
but it only showed a pop-up saying the audio output name.
Thank you.
you could create a keyboard shortcut, you don’t say what desktop your using, so you’ll have to google.
I’m using KDE plasma, I actually googled a lot and tried to mess with the pacmd command, with no results
did you go into the menu & type keyboard, should pop right up.
then just create the command.
pactl list sinks | grep 'Name: '
pactl set-default-sink
Just tried. It doesn’t work. A popup shows that the device has been selected, and if I click on the audio icon in the System Tray, I can see that the new device has been selected, but the audio still outputs to the last device
some apps have to be restarted to use the new settings. they only detect when opened, not while running.
But if I change the device with the icon in the system tray, the audio output switch right away, even if I don’t restart the app
it’s been awhile since i’ve messed with that stuff, check the man pages.
man pactl
Setting the default sink will change the output used for any new stream
To move streams that are already playing use these commands to find the number of the sink-input
and name (or number) of the sink
pactl list short sink-inputs (first number is the sink-input number)
pactl list short sinks
and use this command to move the streams
pacmd move-sink-input [sink-input-number] [sink-name]
lol, he’s going to have to script it, then tie the keyboard shortcut to script.
So,
pactl list short sink-inputs
230 23 9 protocol-native.c float32le 2ch 44100Hz
242 23 51 protocol-native.c s16le 1ch 44100Hz
393 23 9 protocol-native.c float32le 1ch 44100Hz
508 23 9 protocol-native.c float32le 2ch 48000Hz
pactl list short sinks
23 alsa_output.pci-0000_0a_00.3.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
24 alsa_output.pci-0000_08_00.1.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz IDLE
I did
pacmd move-sink-input 230 24
pacmd move-sink-input 242 24
pacmd move-sink-input 393 24
But the audio was in the headphones and remains in the headphones
EDIT: after reboot, I tried again and this time worked, thank you
So, to anyone intrested in, I made a small script that chages the default audio output device and move all the current audio streams to the new output.
pactl set-default-sink *desidered_output*; for p in $(pactl list short sink-inputs | awk '{print $1}'); do pacmd move-sink-input "${p}" *desidered_output*; done
To see the desidered_output, type pactl list short sinks
and pick the index or the name.
If you want to set a keyboard shortcut, use the name, since the index can change when rebooting.
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.