21.03.2009 19:55

Pvol and ossaudiodev

Pvol screenshot My laptop has a lot of extra keys, a few of them for controlling sound. At first I mapped those to change the volume silently with amixer. While I was at a hackmeeting this winter I noticed a few laptops that had internal OSD showing a progress bar on volume changes. I liked that, and recently Gigamo showed me his rvol utility for changing the volume that displays a GTK progress bar. It's written in Ruby and I didn't have ruby-gtk2 bindings to try it (nor wanted to install them).

I considered it a good exercise to rewrite it in Python with pygtk, because so far I used only WxGTK and PythonCard. Good thing that I did as Pylendar was next and it was much easier to write. Anyway pvol.py is a command line utility for changing the volume, showing an optional GTK progress bar. While rvol uses an external utility for actual volume changes I decided to use ossaudiodev, so pvol is standalone. One especially tricky task with it was muting audio channels. I worked with pyalsaaudio before and I like it more but it's not part of the standard Python distribution. Finally I re-mapped my keys to use pvol and I'm very happy with it, it's simple but it makes a difference. Let's see what it actually does:

$ pvol -h

Usage: pvol [-s] [-m] [-c PERCENT] [-p] [-q]

Options:
  -h, --help            show this help message and exit
  -s, --status          display current volume
  -m, --mute            mute the main audio channel
  -c PERCENT, --change=PERCENT
                        increase or decrease volume by given percentage
  -p, --pcm             change PCM channel (default is MASTER)
  -q, --quiet           adjust volume without the progressbar


Written by anrxc | Permalink | Filed under desktop, code, media