You are not logged in.
Hello,
How can I run a script (ran by root) automaticly when switching from battery to ac and ac to battery?
I bet its easy but I don't know where to start.
Thanks,
Tom
Offline
man acpid
M*cr*s*ft: Who needs quality when you have marketing?
Offline
$ pacman -S laptop-mode-tools
Last edited by whargoul (2008-10-14 00:33:40)
Arch - It's something refreshing
Offline
laptop-mode-tools is overkill. All you need is acpid and pm-utils.
I have acpid watch for various events, including the events whose $2=AC or ACAD and whose $4=00000000 when AC is removed, and whose $4=00000001 when AC is restored. Your own acpi events may look slightly different.
I have my acpi handler run "/usr/sbin/pm-powersave true" when the AC is removed and "... false" when the AC is restored. That runs all the scripts distributed with pm-utils in the /usr/lib/pm-utils/power.d/ directory, and also all the scripts I've put in the /etc/pm/power.d directory.
You'll have to read up on acpi and pm-utils to understand how to get this all working, but it's not too hard. Good luck.
Offline
laptop-mode-tools is overkill. All you need is acpid and pm-utils.
I have acpid watch for various events, including the events whose $2=AC or ACAD and whose $4=00000000 when AC is removed, and whose $4=00000001 when AC is restored. Your own acpi events may look slightly different.
I have my acpi handler run "/usr/sbin/pm-powersave true" when the AC is removed and "... false" when the AC is restored. That runs all the scripts distributed with pm-utils in the /usr/lib/pm-utils/power.d/ directory, and also all the scripts I've put in the /etc/pm/power.d directory.
You'll have to read up on acpi and pm-utils to understand how to get this all working, but it's not too hard. Good luck.
Thanks for pointing me in the right direction
Offline