summaryrefslogtreecommitdiff
path: root/acpid-handler.sh
diff options
context:
space:
mode:
authorroot <root@europa5.lan>2009-08-23 13:57:14 +0200
committerroot <root@europa5.lan>2009-08-23 13:57:14 +0200
commitda2f0620a3b4ca216e9e4457a3153eec92954142 (patch)
treea927957537929f2891ce8232179162876215136b /acpid-handler.sh
parent0b39b9c645046896610779dcef0fb6cc0ebe4022 (diff)
downloadminilinux-da2f0620a3b4ca216e9e4457a3153eec92954142.tar.gz
minilinux-da2f0620a3b4ca216e9e4457a3153eec92954142.tar.bz2
added acpid in user land with a simple script being able to to a ACPI powerbutton shutdown (needed for VirtualBox tests)
Diffstat (limited to 'acpid-handler.sh')
-rw-r--r--acpid-handler.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/acpid-handler.sh b/acpid-handler.sh
new file mode 100644
index 0000000..4f3ee32
--- /dev/null
+++ b/acpid-handler.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Default acpi script that takes an entry for all actions
+
+# NOTE: This is a 2.6-centric script. If you use 2.4.x, you'll have to
+# modify it to not use /sys
+
+minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
+maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
+setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
+
+set $*
+
+case "$1" in
+ button/power)
+ #echo "PowerButton pressed!">/dev/tty5
+ case "$2" in
+ PWRF)
+ logger "PowerButton pressed: $2"
+ poweroff
+ ;;
+ *) logger "ACPI action undefined: $2" ;;
+ esac
+ ;;
+ button/sleep)
+ case "$2" in
+ SLPB) echo -n mem >/sys/power/state ;;
+ *) logger "ACPI action undefined: $2" ;;
+ esac
+ ;;
+ ac_adapter)
+ case "$2" in
+ AC)
+ case "$4" in
+ 00000000)
+ echo -n $minspeed >$setspeed
+ #/etc/laptop-mode/laptop-mode start
+ ;;
+ 00000001)
+ echo -n $maxspeed >$setspeed
+ #/etc/laptop-mode/laptop-mode stop
+ ;;
+ esac
+ ;;
+ *) logger "ACPI action undefined: $2" ;;
+ esac
+ ;;
+ battery)
+ case "$2" in
+ BAT0)
+ case "$4" in
+ 00000000) #echo "offline" >/dev/tty5
+ ;;
+ 00000001) #echo "online" >/dev/tty5
+ ;;
+ esac
+ ;;
+ CPU0)
+ ;;
+ *) logger "ACPI action undefined: $2" ;;
+ esac
+ ;;
+ button/lid)
+ #echo "LID switched!">/dev/tty5
+ ;;
+ *)
+ logger "ACPI group/action undefined: $1 / $2"
+ ;;
+esac