Adjust Volume Control

What could we do if we don't have those special keys on our keyboard to adjust the volume level, or we can not use them under the Linux distro of our choice? We could write a script with a suitable command and assign a global shortcut to this script. It is basically that simple. But if we don't show the actual volume level on the display this solution won't be of much use. On the other hand, we can't display the actual level correctly if we start after every keyboard hit a new instance of our application. Then so we would have a dozen of popup windows overlapping each other and this is not only ugly but also useless because the last visible window most probably won't be the correct indicator. My solution is the use of FIFO. This enables us to create a communication pipe between two instances of our application. If another instance is already running the application won't create an own window, instead it will pass the argument (UP or DOWN) to the existing instance via the communication pipe (FIFO) and exit.

All we need now are two global keyboard shortcuts to our application with different arguments. Assign for example CTRL+SHIFT+DOWN to the command adjust_vol DOWN and CTRL+SHIFT+UP to the command adjust_vol UP.

Type the following command to compile the program:

gcc -Wall `pkg-config --cflags --libs gtk+-2.0` -o adjust_volume adjust_volume.c

Note that this solution will only work if you have aumix (a command line mixer) on your system installed.

Download source code here.





Make a free website with Yola