Changing sound volumes in Openbox
December 19, 2007
You can use several applications to adjust the volume. Try alsamixer, a command-line mixer for alsa which comes with ubuntu (part of alsa-utils), or one of the many frontends for it: alsamixergui; qamix, a Qt front-end for alsamixer; gamix, a Gtk front-end; or (if you can tolerate gnome dependencies) gnome-alsamixer. You can also use xfce4-mixer, though it loads xfce-mcs-manager which might interfere with your gtk settings if you use another method to apply these. You can use all of these to control the volume, 3D switches, the volume of CD audio, line-in, headphones, phone, etc.
There are also several dockapps available to adjust the volume. Have a look here.
Several panels also have plugins to adjust the volume: this is the case for the lxpanel, perlpanel, xfce4-panel (using xfce4-mixer), gnome-panel, and kicker.
While all these applications may be useful, it is generally easier to change the volume by pressing a single key or a combination of keys on your keyboard. How can you accomplish this in Openbox?
The following commands turn the volume up and down:
- Up: amixer -q set PCM 1+ unmute
- Down: amixer -q set PCM 1- unmute
To toggle mute, use the following command:
- amixer -q set PCM toggle
If you’d rather change the master volume (as opposed to the PCM), use the following commands:
- Up: amixer -q set Master 1+ unmute
- Down: amixer -q set Master 1- unmute
- Mute: amixer -q set Master toggle
To make these commands more convenient, assign keyboard bindings to them in the rc.xml file. I use Ctrl+Up, Ctrl+Down, and Ctrl+Alt+End to turn the volume up, down and on/off. If you are more of a mouse person, you could also use a dockapp with launchers and assing the above commands to some launchers.
If you like an on-screen display when you change the volume, you can use OSDsh, a small application that shows the volume levels of your soundcard whenever they change. It is in the Ubuntu repositories.
In order to use OSDsh, you have to run it in the background. Install the application (duh!), and add the following lines to your autostart file (~/.config/openbox/autostart.sh):
osdsh & (sleep 1 && osdctl -m 1) &
You can use themes to adjust the looks of OSDsh. To create your own themes, use the command “osdshconfig“. Themes allow you to change the colours, position, fonts, shadow offset, outline width and the delay of the on-screen-display. To apply them, use the following command in your autostart file, after “osdsh &”:
osdctl -S /path/to/your/theme/file