#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-1.0.4-default.sh,v 1.1 2005/03/15 19:15:53 ciaranm Exp $

# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
	button)
		case "$action" in
			power)	/sbin/init 0
				;;
			*)	logger "ACPI action $action is not defined"
				;;
		esac
		;;
	ac_adapter)
		case "$*" in
			"ac_adapter AC 00000080 00000000")
				/bin/echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
				/opt/ati/bin/fglrx_pplay -t 2
				;;
			"ac_adapter AC 00000080 00000001")
				/bin/echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
				/opt/ati/bin/fglrx_pplay -t 1
				;;
		esac
		;;
	ibm)
		case "$*" in
		        # Fn+F12
		        "ibm/hotkey HKEY 00000080 0000100c")
		        #        /usr/sbin/hibernate
		                ;;
		        # Fn+F4
		        "ibm/hotkey HKEY 00000080 00001004")
		                /usr/sbin/hibernate-ram
		                ;;
		        # Fn+F6
		        "ibm/hotkey HKEY 00000080 00001006")
		                ;;
		        # Fn+F8
		        "ibm/hotkey HKEY 00000080 00001008")
		                ;;
		        # Fn+F3
		        "ibm/hotkey HKEY 00000080 00001003")
		                ;;
		        # log everything else to syslog
		        *)
		                /usr/bin/logger -i -t "IBM Special Button" $1
		                ;;
		esac
		;;
	*)
		logger "ACPI group $group / action $action is not defined"
		;;
esac

