#!/bin/sh # # anrxc's acpid handler for Acer TravelMate 5320 # # Power button starts a system shutdown. # Sleep button suspends the machine to ram. # - delegated this to my WM (Fn+F3 to disk, Fn+F4 to ram) # AC events control CPU throttling. # - now they start laptop_mode which also takes care of that # Battery events should auto-hibernate on low battery trough laptop_mode. # - my battery doesn't report back and has no alarm support # Lid handler locks the screen when someone tries to open it. # - there is no need for it to be running while lid is closed # - included are commands to power on/off the panel # - that's automatic on my hardware throttle="/proc/acpi/processor/CPU0/throttling" set $* case "$1" in button/power) case "$2" in PWRF) /sbin/shutdown -h now ;; *) logger "ACPI action undefined: $2" ;; esac ;; button/sleep) case "$2" in SLPB|SBTN) #/usr/sbin/pm-suspend ;; *) logger "ACPI action undefined: $2" ;; esac ;; ac_adapter) case "$2" in AC|ADP1) case "$4" in 00000000) /usr/sbin/laptop_mode auto #echo -n 1 >$throttle ;; 00000001) /usr/sbin/laptop_mode auto #echo -n 0 >$throttle ;; esac ;; *) logger "ACPI action undefined: $2" ;; esac ;; battery) case "$2" in BAT0) case "$4" in 00000000) #/usr/sbin/laptop_mode auto #echo "BAT offline" >/dev/tty5 ;; 00000001) #/usr/sbin/laptop_mode auto #echo "BAT online" >/dev/tty5 ;; esac ;; CPU0) ;; *) logger "ACPI action undefined: $2" ;; esac ;; button/lid) case "$2" in LID0) grep -q open /proc/acpi/button/lid/*/state if [ $? = 0 ]; then DISPLAY=":0.0" XAUTHORITY=/home/anrxc/.Xauthority /usr/bin/sudo -u anrxc /usr/lib/kde4/libexec/kscreenlocker --forcelock #XAUTHORITY=/home/anrxc/.Xauthority /usr/bin/xset -display :0.0 dpms force on logger "ACPI action executed: DPMS forced on / screen lock" else XAUTHORITY=/home/anrxc/.Xauthority /usr/bin/xset -display :0.0 dpms force off logger "ACPI action executed: DPMS forced off" fi ;; *) logger "ACPI action undefined: $2" ;; esac ;; *) logger "ACPI group/action undefined: $1 / $2" ;; esac