openmind ☃   March 13, 2007  ☃  wmii: Multimedia Keys HOWTO  (, , )

I can’t claim this hack, as the Greek(s)1 at this page figured it out for me. It’s pretty sweet though, so we’ll call this a translation.

First setup ~/.Xmodmap

4054 [0] ~ $ cat ~/.Xmodmap 
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 153 = XF86AudioNext
keycode 144 = XF86AudioPrev
keycode 164 = XF86AudioStop
keycode 160 = XF86AudioMute
keycode 162 = XF86AudioPause 

Then adjust the keys section of ~/.wmii-<version>/wmiirc:

wmiir write /keys <<EOF
...
XF86AudioLowerVolume
XF86AudioRaiseVolume
XF86AudioMute
EOF

Next add an action for each key:

while read event 
do
	...
	case "$type" in
	...
	Key)
 		case "$1" in
		...
		XF86AudioLowerVolume)
		amixer -q set PCM 2dB- unmute &>/dev/null &;;
                XF86AudioRaiseVolume)
                amixer -q set PCM 2dB+ unmute &>/dev/null &;;
                XF86AudioMute)
                amixer -q set Master toggle &>/dev/null &;;

Hacking ~/.wmii-<version>/status is also more fun than is probably healthy:

4056 [0] ~ $ cat ~/.wmii-3.5/status 
#!/bin/sh
#periodically print date and load average to the bar
xwrite() {
        file="$1"; shift
        echo -n "$@" | wmiir write "$file"
}
wmiir remove /rbar/status 2>/dev/null && sleep 2
echo $WMII_SELCOLORS | wmiir create /rbar/status
while xwrite /rbar/status "$WMII_NORMCOLORS" `date "+%T %Y.%m.%d"` `amixer -d get PCM|grep 'Left:'|awk '{print $5}'`
do
        sleep 1
done

1 Note, that says “Greek,” not “Geek”…

blog comments powered by Disqus