#!/bin/sh

# keydown
# return 1 for led on, 0 for led off

case $1 in
	3)	if pidof smbd; then
			/etc/init.d/samba stop
			exit 0
		else
			/etc/init.d/samba start
			exit 1
		fi
	;;
	4)	if pidof X; then
			killall -w Xorg
			exit 0
		else
			start-stop-daemon -b -c matteo:matteo -S -x /usr/bin/startx
			while ! pidof enlightenment; do
				sleep .2
			done
			exit 1
		fi
	;;
	5)
		awk '/^\/dev\/sd[b-z]/{print$1}' /proc/mounts |xargs -rn1 umount
		exit 0
	;;
esac
