#!/bin/sh # # anrxc's acpid handler for HP ProBook 4320s # # Power button starts a system shutdown. # Sleep button suspends the machine to ram. # - delegated this to my WM (Fn+F6 to disk, Fn+F1 to ram) # AC events start laptop_mode (which also controls cpufreq or throttling). # Battery events auto-hibernate on low battery through laptop_mode. # Lid handler locks the screen when someone tries to open it. 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) case "$2" in PWRF|PBTN) logger "PowerButton pressed: $2 - system shutdown" /sbin/shutdown -h now ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; button/sleep) case "$2" in SLPB|SBTN) logger "SleepButton pressed: $2 - not suspending" #/usr/sbin/pm-suspend ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; ac_adapter) case "$2" in AC|ACAD|ADP0|ADP1|ACPI0003:00) case "$4" in 00000000) #/usr/sbin/laptop_mode auto /etc/rc.d/laptop-mode restart #echo -n $minspeed >$setspeed ;; 00000001) #/usr/sbin/laptop_mode auto /etc/rc.d/laptop-mode restart #echo -n $maxspeed >$setspeed ;; esac ;; *) /usr/bin/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) ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; video/brightnessup) case "$2" in BRTUP) /usr/bin/logger "ACPI action executed: no action for brightnessup" ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; video/brightnessdown) case "$2" in BRTDN) /usr/bin/logger "ACPI action executed: no action for brightnessdown" ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; button/lid) case "$3" in close) XAUTHORITY=/home/anrxc/.Xauthority /usr/bin/xset -display :0.0 dpms force off /usr/bin/logger "ACPI action executed: DPMS forced off" ;; open) XAUTHORITY=/home/anrxc/.Xauthority /bin/su anrxc -c "/usr/lib/kde4/libexec/kscreenlocker --forcelock --display :0.0" && /usr/bin/nitrogen --restore /usr/bin/logger "ACPI action executed: screen lock" ;; *) /usr/bin/logger "ACPI action undefined: $2" ;; esac ;; *) /usr/bin/logger "ACPI group/action undefined: $1 / $2" ;; esac