#!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions

set $*
export DISPLAY=:0.0
group=${1/\/*/}
action=${1/*\//}
device=$2
id=$3
value=$4

log_unhandled() {
	logger "ACPI event unhandled: $*"
}

case "$group" in
	button)
		case "$action" in
			power)
				/sbin/init 0
				;;

			# if your laptop doesnt turn on/off the display via hardware
			# switch and instead just generates an acpi event, you can force
			# X to turn off the display via dpms.  note you will have to run
			# 'xhost +local:0' so root can access the X DISPLAY.
			#lid)
			#	xset dpms force off
			#	;;
			sleep)
				/sbin/init 6
				;;
			*)	log_unhandled $* ;;
		esac
		;;
	hotkey) 
		case "$id" in
			00000030)	
				/usr/local/bin/acpi_fakekey 201 
				;;
			00000031)	
				/usr/local/bin/acpi_fakekey 200
				;;
			00000032)	
				/usr/local/bin/acpi_fakekey 199
				;;
			00000045)
				/usr/local/bin/acpi_fakekey 202
				;;
			00000043)
				/usr/local/bin/acpi_fakekey 203
				;;
			0000005d)
				/usr/local/bin/acpi_fakekey 204
				;;
			0000005c) 
				/usr/local/bin/acpi_fakekey 205
				;;
			0000006a) 
				/usr/local/bin/acpi_fakekey 206
				;;
			00000052) 
				/usr/local/bin/acpi_fakekey 207
				;;
		esac
		;;
	ac_adapter)
		case "$value" in
			# Add code here to handle when the system is unplugged
			# (maybe change cpu scaling to powersave mode)
			#*0)
			#	;;

			# Add code here to handle when the system is plugged in
			# (maybe change cpu scaling to performance mode)
			#*1)
			#	;;

			*)	log_unhandled $* ;;
		esac
		;;

	*)	log_unhandled $* ;;
esac

