You are not logged in.
Hi mates,
i have this problem, i wrote a little acpi script to take care of power management, that works on plug/unplug of the AC, but it doesn't get executed on boot.
This is the /etc/acpi/events/acadapter
# Pass ac_adapter events
event=ac_adapter.*
action=/etc/acpi/actions/acadapter.sh "%e"
This is the /etc/acpi/actions/acadapter.sh
set $*
case "$2" in
AC|ACAD|ADP0)
case "$4" in
### AC Adapter Disconnected
00000000)
# DO SOMETHING
;;
### AC Adapter Connected
00000001)
# DO SOMETHING
;;
esac
;;
*) logger "ACPI action undefined: $2" ;;
esac
As root i can manually trigger the script with something like
/etc/acpi/actions/acadapter.sh 0 ACAD 0 $([ "$(cat /sys/class/power_supply/ACAD/online)" = "1" ] && echo "00000001" || echo "00000000")
but the problem is that placing that line on /etc/rc.local doesn't work and i can't get the power management running if i start the laptop on battery. Also, i don't know if it's possible to send an ac_adapter event to trigger the script.
Any hints?
Last edited by cyrusza (2011-06-03 10:30:15)
Offline
Uhm, i'm thinking of migrating the "DO SOMETHING" part to some pm-powersave hook, so i can check for AC and launch pm-powersave on rc.local...
Offline
Maybe install acpid, add it to your /etc/rc.conf and modify the created /etc/acpi/handler.sh?
Offline
Maybe install acpid, add it to your /etc/rc.conf and modify the created /etc/acpi/handler.sh?
ACPID is installed and correctly started or i'd never be able to catch the events. I ditched handler.sh and used different scripts to handle the "buttons" and "AC" events, to keep the code more readable (the DO SOMETHING part is large).
Offline
Ok i got all working migrating the power management stuff to pm-utils.
I also deleted all the acpi event catcher scripts and returned to the single /etc/acpi/handler.sh. If it can be of interest to someone, the relevant part of the configuration is the following:
/etc/acpi/handler.sh
...
...
### AC adapter connected/disconnected
ac_adapter)
case "$2" in
AC|ACAD|ADP0)
case "$4" in
00000000)
logger -t ACPI "AC adapter disconnected: $4"
/usr/sbin/pm-powersave true
;;
00000001)
logger -t ACPI "AC adapter connected: $4"
/usr/sbin/pm-powersave false
;;
esac
;;
*)
logger -t ACPI "ACPI action undefined: $2"
;;
esac
;;
...
...
/etc/rc.local
...
[ "$(cat /sys/class/power_supply/ACAD/online)" = "1" ] && /usr/sbin/pm-powersave false || /usr/sbin/pm-powersave true
...
Then all the additional hooks must reside in /etc/pm/power.d/ (the standard ones are located in /usr/lib/pm-utils/power.d/).
Eventual hooks that involve X need to be replicated in something like .xinitrc, because pm-powersave in rc.local can't access the DISPLAY when X is not running.
Last edited by cyrusza (2011-06-01 19:31:07)
Offline