#!/bin/bash

#This script runs a default command, if the modifier has not been pressed.
#If modifier pressed once, it runs a second command
#"      "      "    twice, "   "   " third      "
#"        "     "   fourth wrap around. Nay blow up the world

#exec()'s are for speed.

#My keyboard is a wireless logitech keyboard. Concider keeping these bindings if you own one!
#Have a look in http://...../../music for my programs that do funky things with music and the volume keys!


key=$1
mod=$2

echo key=$key

case "$key" in
	0x20)
		exec togglevolmute
	;;
	0x2e)
#		exec mastvoldown
		pcmvoldown
		exec cdvoldown
	;;
	0x30)
#		exec mastvolup
		pcmvolup
		exec cdvolup
	;;
	0x22)	
#		echo play/pause
		exec musicpause $mod
	;;


	0x10)	
#				echo back
		exec musicrew $mod
	;;
	0x19)	
#				echo forw
		exec musicfwd $mod
	;;
	0x24)	
#				echo stop
		exec musicstop $mod
	;;
	0x6c)	
#				echo mail
		exec xterm -rv -e ssh -t -l tcon suphys "pine"
	;;
	0x66)	
#				echo favourites
				if [ $mod = 0 ] ; then
					exec xemacs -f desktop-read
				elif [ $mod = 1 ] ; then
					exec 4xtermremote tcon@hera tcon@hera tcon@hera tcon@hera
                                else
                                        exec 4xtermremote localhost localhost localhost localhost 
				fi
	;;
	0x32)	
#				echo home
                if [ $mod = 0 ] ; then
			exec mozilla
		else
			exec xterm -ls -rv
		fi
	;;
	0x6b)	
#				echo mycomp
		exec xterm -rv -ls
	;;
	0x21)	
#				echo calc
		exec xcalc
	;;
	0x5f)   
#				echo sleep
		if [ "$mod" = 1 ] ; then
			exec apmdown -S
		else
			exec apmdown
		fi
	;;
esac
