You are not logged in.

#1 2013-11-12 23:01:17

Darakus
Member
From: usa
Registered: 2011-07-05
Posts: 6

[Solved] Volume keys and switching sound outputs through pulseaudio

Greetings.

Background:
My motherboard has normal analog sound outputs as well as digital optical output (SPDIF).
I'm running xfce4

Problem:
When I use pavucontrol to switch from my headphones to my stereo system, the audio will switch, but I can no longer control the volume with the volume keys on my keyboard

Question:
Is there a way for me to get my volume keys to correspond with whatever sound output is currently selected?


Any suggestions are greatly appreciated. Thanks.

Last edited by Darakus (2013-11-13 17:39:20)

Offline

#2 2013-11-13 06:35:49

alezost
Member
Registered: 2013-10-17
Posts: 61

Re: [Solved] Volume keys and switching sound outputs through pulseaudio

https://wiki.archlinux.org/index.php/Xf … me_Buttons can tell you how keys are set up for PulseAudio in XFCE.

Basically i think you need to define the index of the current device with some other pactl command (or with a more complex shell command) like this:

pactl set-sink-volume $(pactl ...) +1%

That's only a guess, because I don't use neither PulseAudio nor XFCE.

Offline

#3 2013-11-13 15:54:10

Darakus
Member
From: usa
Registered: 2011-07-05
Posts: 6

Re: [Solved] Volume keys and switching sound outputs through pulseaudio

Thanks for the input.

My plan now is to modify the script that runs when I hit my volume buttons to detect which device is selected to play sound and then change only the volume on that device. It sounds simple but I'm not exactly a bash expert. I'll post back here if I get anything useful.

Offline

#4 2013-11-13 17:31:44

Darakus
Member
From: usa
Registered: 2011-07-05
Posts: 6

Re: [Solved] Volume keys and switching sound outputs through pulseaudio

After trying the pulseaudio-ctl package from the AUR and having it produce unexpected results, I began to examine the code of the package. It turns out there was a simple awk command used in this package that does exactly what I need it to do. I wish I could say that I wrote any of this solution, but I did not, its a combination of whats on the xfce4 wiki page and in pulseaudio-ctl.

CURRENTSINK=$(pacmd list-sinks | awk '/* index:/ { print $3 }')
pactl set-sink-mute $CURRENTSINK false
pactl set-sink-volume $CURRENTSINK +3%

I set this script to execute when I hit the volume up button on my keyboard. A similar script runs for volume down and mute.

Offline

Board footer

Powered by FluxBB