Sunday, February 24, 2008

Volume buttons

How to get on screen display when the volume / mute button is pressed.

1. emerge xosd

2. Create the executable files that will be executed when the buttons are pressed. For me, down.sh (when 'Volume decrease" is pressed), up.sh (Volume increase) and mute.sh (toggle between mute and unmute)
Contents of down.sh

amixer set Master 5%-
killall osd_cat
osd_cat -p middle -A center -f "-adobe-new century schoolbook-medium-i-normal--34-240-100-100-p-182-iso8859-1" -c blue -b percentage -P `amixer sget Master |grep "Front Left: Playback" |cut -c 28-30` -T `amixer sget Master |grep "Front Left: Playback" |cut -c 28-30` -d 2 &
Contents of up.sh

amixer set Master 5%+
killall osd_cat
osd_cat -p middle -A center -c blue -f "-adobe-new century schoolbook-medium-i-normal--34-240-100-100-p-182-iso8859-1" -b percentage -P `amixer sget Master |grep "Front Left: Playback" |cut -c 28-30` -T `amixer sget Master |grep "Front Left: Playback" |cut -c 28-30` -d 2 &
Contents of mute.sh

killall osd_cat
if /usr/bin/amixer sget Master | grep -q "Front Left: Playback 0 \[0%\]"
then
echo "Volume unmuted" | osd_cat -p bottom -A center -f "-adobe-new century schoolbook-medium-i-normal--34-240-100-100-p-182-iso8859-1" -c green -d 2 &
amixer set Master 75%+ on ## the 'on' allows the LED button turn blue
else
echo "Volume muted" | osd_cat -p bottom -A center -f "-adobe-new century schoolbook-medium-i-normal--34-240-100-100-p-182-iso8859-1" -c green -d 2 &
amixer set Master 0 off ## LED button turns orange
fi

3. Map the appropriate keycodes to the volume buttons by using xev into .Xmodmap.

4. Edit ~/.fluxbox/keys so that the respective files (down.sh, up.sh, mute.sh) will be executed when the respective buttons are pressed.

None XF86AudioRaiseVolume :ExecCommand ~/bin/up.sh
None XF86AudioLowerVolume :ExecCommand ~/bin/down.sh
None XF86AudioMute :ExecCommand ~/bin/mute.sh

Monday, February 11, 2008

Starting different window managers

I start up my window manager (Fluxbox) by command line 'startx'. However, sometimes I want to experiment with other managers and it becomes a chore editing the .xinitrc every now and then. Instead, I use 'xinit':

xinit /home/username/bin/fluxbox
xinit /home/username/bin/beryl
Content of ~/bin/fluxbox:
for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
do
if ( cp /dev/null "$errfile" 2> /dev/null )
then
chmod 600 "$errfile"
exec > "$errfile" 2>&1
break
fi
done

exec startfluxbox
Content of ~/bin/beryl:

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
eval `dbus-launch --sh-syntax --exit-with-session`
fi

emerald &
beryl-manager &

# Start other applications here
#
# Example: set wallpaper + open a terminal
#
#fbsetbg -f /home/username/Personal/Bild/Hintergrund/nix.jpg &
#exec rox -p Default -b Default -S &
exec /usr/local/sbin/rox-session
exec beryl