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

set $*

group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4

if [ "$group" = "ibm" ]
then
	key="$2"\ "$3"\ "$4"
fi

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

case "$group" in
	button)
		case "$action" in
			power)
				logger "acpid: *power* button pressed '$device' '$id' '$value';"
				if [ "$device" = "PBTN" ]
				then
					/usr/local/bin/acpi_fakekey 184
				fi
				#/sbin/init 0
				;;
			lid)
				logger "acpid: *lid* event triggered;"
				/usr/local/bin/lid.sh
				;;
			*)	log_unhandled $* ;;
		esac
		;;
	ac_adapter)
		case "$value" in
			*0)
				logger "acpid: AC adapter disconnected;"
				cpupower frequency-set -g powersave
				;;
			*1)
				logger "acpid: AC adapter connected;"
				cpupower frequency-set -g performance
				;;

			*)	log_unhandled $* ;;
		esac
		;;
	battery)
		logger "acpid: battery capacity changed;"
		/usr/local/bin/low_battery_handler.sh
		;;
	*)	log_unhandled $* ;;
esac
#battery PNP0C0A:00 00000080 00000001
