icewm is probably my favourite window manager for X. When I'm using a UNIX system. Here is a screenshot:
Why do I love it? Well, for one thing on my system it is consuming about 10MB of RAM. Actually I'm running icewm-session so it's a bit more but really I only need the icewm part. So that is one reason, here are two others:
OK so these are mainly about key bindings, but I just find that these defaults come naturally to me, and I find using icewm much more productive and straightforward than other wm. Mainly because I don't really need a menu and all that crap, I just need lots of shells and a way to switch between windows.
Anyway, to get the point of this post, icewm doesn't have a volume control thing. Lots of people have written them but it occurred to me that I didn't want to waste resources running some stupid thing just to change volume. I mean, how often do I change volume? Not very often. So why have an app running in the background dilligently waiting for my commands? No, it would be a waste.
On FreeBSD, controlling the volume of the soundcard is done via the mixer command. It is simple, mixer on its own lists all of the soundcard mixer values: line in, cd, pcm, etc. And changing say the volume is done by "mixer vol 30" to set it to 30. So I thought, fuckit, why not just write something in python in a few minutes to do this with a slider. Well here it is:
#!/usr/local/bin/python import commands from Tkinter import Tk,IntVar,Scale def adjustVol(vol): commands.getoutput("/usr/sbin/mixer vol "+vol) return root = Tk() root.geometry('50x100+80+620') vol = IntVar() scale = Scale(root,variable=vol,from_=100,to=0,command=adjustVol) scale.set(commands.getoutput('/usr/sbin/mixer -S').split(':')[1]) scale.pack() root.mainloop()
That's it! The code simply creates a Tk window with a slider and sets the value accordingly. Since I wasn't making it generic, I just hard coded the screen position so that it came above the volume icon I added to the icewm toolbar. Here it is in action:
icewm toolbar then has an entry like this:
prog MixerControl vol_16x16.png /path/to/mixerapp.py
I got the icon image by searching on google images using the imagesize:16x16 modifier.