Friday, February 29, 2008

pypanel volume control

not long ago i tried to use xfce4, and i really disliked that thunar depends on gnome libs for some stuff.
so i started to think about moving to another DE or even WM.
i wanted really fast and light one.
so now i'm trying OpenBox.

it doesn't have own panel, so i use pypanel.
the only thing i dislike about it is the lack of volume control.

so i wrote my own.
here's the patch against pypanel-2.4: http://wakeroid.googlepages.com/pypanel-volume.diff

and you'll need to add this to .pypanelrc:


VOLUME = N # where N is volume control position, 0 to disable
import alsaaudio;
mixer = alsaaudio.Mixer('PCM')

def volumeButtonEvent (pp, button):
if button == 4:
mixvolume = mixer.getvolume()[0]
mixvolume += 5
if mixvolume > 100:
mixvolume = 100
mixer.setvolume (mixvolume)
elif button == 5:
mixvolume = mixer.getvolume()[0]
mixvolume -= 5
if mixvolume < 0:
mixvolume = 0
mixer.setvolume (mixvolume)

6 comments:

Derrick said...

it would be great if you submitted this to the pypanel developers for inclusion.

waker said...

i don't think it's possible.
you see, pypanel is a cross-platform app, and my patch requires alsa (thus works under linux only).
hovewer, some other stuff from my patch is portable (i have much better looking panel, than what default pypanel allows)

uterrorista said...

where do i put pypanel-volume.diff and the text?
Thanks.

waker said...

uterrorista, you should apply it using patch command.
man patch for more detail.

it should look somewhat like this:
tar zxvf pypanel-2.4.tar.gz
cd pypanel-2.4
patch -p0 <pypanel-volume.diff
./configure
make
make install

Eren said...

I got some errors related to lgc is not set...
as you see if following options are not on then script gives error...
# Misc. initializations
if SHOWLINES or SHOWBORDER:
self.lgc = self.root.create_gc(foreground=self.getColor(LINE_COLOR))

waker said...

eren,
i'm sorry to tell this, but i moved to bmpanel, and i don't have enough time to maintain this. probably you can fix it yourself.