Monday, October 25, 2010

Volume Keys Without Pulseaudio On Ubuntu

I have always wondered the need for pulseaudio on Linux desktops. There are many reasons to think so. One of the most important stated objectives behind pulseaudio, simultaneous access to sound cards, was never a problem in the presence of ALSA plugins dmix and dsnoop. Note that dmix and dsnoop are turned on by default on Ubuntu. This means that in the absence of pulseaudio, multiple applications can still access the sound card at the same time. Other than the misleading motive, pulseaudio suffers from implementation challenges: it is a CPU hog, some applications mysteriously lose their audio with it, and audio stutters under CPU load. In my opinion, Ubuntu should really revisit their decision to ship pulseaudio. 

Unfortunately, on Ubuntu 10.04 and 10.10, if pulseaudio is uninstalled, the volume keys on laptops and or the volume keys/knobs on some fancy keyboards, do not work at all. In this situation there is no way to change the volume except using the ALSA utilities, alsamixer or amixer. To workaround this deficiency and also to learn a bit of DBus programming, I wrote a perl script to enable the use of volume keys when pulseaudio is not installed. The script also displays the changed volume in the notification area. I should point out that the script does not replace the functionality of a sound mixer such as gnome-volume-control or alsamixer. 

Download the script, volumekey.pl from the link below and save it to your ~/bin/volumekey.pl. Note that the script requires the following packages: libnet-dbus-perl, libdesktop-notify-perl, and alsa-utils. Make sure that these packages are installed on your machine.


https://docs.google.com/leaf?id=0B5pBVMJp4F1PMzY3MjMxOGYtYmE1ZS00ZWMzLThjNGMtNGY1ZmQ5ZGFkNzE5&sort=name&layout=list&num=50


Add the script to your System->Preferences->Startup Applications.

No comments: