[pulseaudio-discuss] Newbie: controlling volume through command line
gmane at colin.guthr.ie
Tue Aug 23 05:16:37 PDT 2011
'Twas brillig, and Jesse Sheidlower at 23/08/11 10:42 did gyre and gimble:
> Hi. I'm sorry to ask a relatively basic question on what seems like a
> pretty high-powered dev list, but I'm having trouble finding the answer
> I'm using PulseAudio on Debian under Xfce. I want to bind keys to
> commands that raise and lower the volume (typically multimedia keys,
> though my current keyboard doesn't actually have these). That's it.
> There are a few discussions about how to do this online, including
> The problem is, these commands only control one sink. I have two USB
> audio controllers and the internal sound card (and a virtual device to
> play everything together), and would like to be able to control whatever
> happens to be playing at any time. (Typically I have a music player
> going through a USB controller, and the rest of my system going through
> the internal card; I'm not usually listening to both simultaneously, but
> this is possible.) So maybe this is more of a question about shell
> coding, but either way, I'd think that it's something that would be of
> interest to many Pulse users.
To solve this properly there needs to be some kind of semi-automatic
intelligence built in to whatever processes the keys. e.g. under Gnome
that would be gnome-settings-daemon, under KDE it's kmix etc.
Really lots of things come into the equation. If you are playing a
movie, then maybe it's the top most window's sound you want to control.
If you are playing music then generally the app is not in the
foreground, so that logic fails etc.
But some kind of virtual device for volume control could be useful. e.g.
a special API that changed the "most appropriate" volume, perhaps based
on the logic of:
1. Are any devices playing sound? If so, pick it. If multiple, use
$algorithm to pick the right one.
2. If nothing is playing, use the default device.
Now, this only applies when dealing with your keyboard or laptop volume
keys. When dealing with the keys from e.g. a USB or Bluetooth headset,
then the volume should control the device it's attached to, not follow a
So as you can see things are much more involved than they may at first
seem. When dealing with policy like this it's really something you want
to build into PA, not just script from the command line.
So really a proper proposal on how to intelligently pick which device to
control and somehow make this policy somewhat configurable (as you'll
certainly get people complaining that it doesn't fit their need) is
Tribalogic Limited [http://www.tribalogic.net/]
Mageia Contributor [http://www.mageia.org/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
More information about the pulseaudio-discuss