HAL erkennt nicht wenn der Stecker herausgezogen wird, da ein entsprechender Kernelevent nicht ausgelöst wird.
Nachfolgender Workaround veranlasst ACPI diese Eigenschaft für den Hal zu setzen:
#!/bin/sh
# Tried on Gentoo
# cpu throttling is in here it is the cpufreq-set lines
# turning swap off is only for those that feel comfortable
# doing something this nasty.
# comment out the laptop_mode line if you don't have it installed
# pcfe, 2008-10-28
# spindown time for HD (man hdparm for valid values)
# I prefer 2 hours for acad and 2 min for batt
ACAD_HD=244
BATT_HD=24
# Power management level
# 255 (off) on AC
# 128 (medium) on batt
# lowered to 32, pcfe, 2004-06-23
# upped to 64, pcfe, 2004-07-14
# upped to 96, pcfe, 2004-10-20
ACAD_PM=255
BATT_PM=96
#Wechsle den Runlevel wenn unplugged bzw. plugged wurde
RUNLEVEL_AC="default"
RUNLEVEL_BATTERY="battery"
# ac/battery event handler
status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/AC/state`
if [ "$status" = "off-line" ]
then
logger "Setze Hald auf ac_adapter.present = false"
hal-set-property --udi $(hal-find-by-capability --capability ac_adapter) --key ac_adapter.present --bool false
logger "Turning off swap."
/sbin/swapoff -a
/usr/bin/cpufreq-set -c 0 -g conservative
/usr/bin/cpufreq-set -c 1 -g conservative
if [ -d "/etc/runlevels/$RUNLEVEL_BATTERY" ]
then
if [[ "$(</var/lib/init.d/softlevel)" != "$RUNLEVEL_BATTERY" ]]
then
logger "Switching to $RUNLEVEL_BATTERY runlevel"
/sbin/rc $RUNLEVEL_BATTERY
fi
fi
else
logger "Setze Hald auf ac_adapter.present"
hal-set-property --udi $(hal-find-by-capability --capability ac_adapter) --key ac_adapter.present --bool true
logger "Turning on swap."
/sbin/swapon -a
/usr/bin/cpufreq-set -c 0 -g ondemand
/usr/bin/cpufreq-set -c 1 -g ondemand
if [ -d "/etc/runlevels/$RUNLEVEL_AC" ]
then
if [[ "$(</var/lib/init.d/softlevel)" != "$RUNLEVEL_AC" ]]
then
logger "Switching to $RUNLEVEL_AC runlevel"
/sbin/rc $RUNLEVEL_AC
fi
fi
fi
Die ermittelten Keycodes kann man im ACPI Script einbauen um entsprechende Effekte zu erzielen
Sony VGN-BZ13XN bright- sony/hotkey SNC 00000001 00000010 (press) sony/hotkey SNC 00000001 0000003b (release) bright+ sony/hotkey SNC 00000001 00000011 (press) sony/hotkey SNC 00000001 0000003b (release) LCD/EXT sony/hotkey SNC 00000001 00000012 (press) sony/hotkey SNC 00000001 0000003b (release) zoom- sony/hotkey SNC 00000001 00000014 (press) sony/hotkey SNC 00000001 0000003b (release) zoom+ sony/hotkey SNC 00000001 00000015 (press) sony/hotkey SNC 00000001 0000003b (release) sleep sony/hotkey SNC 00000001 00000017 (press) sony/hotkey SNC 00000001 0000003b (release) s1 sony/hotkey SNC 00000001 00000020 (press) sony/hotkey SNC 00000001 00000038 (release)