You are not logged in.

#1 2008-10-13 22:18:31

tomdbike
Member
Registered: 2008-09-07
Posts: 25

Running a script when switching battery and ac automaticly?

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

#2 2008-10-13 22:49:49

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: Running a script when switching battery and ac automaticly?

man acpid

M*cr*s*ft: Who needs quality when you have marketing?

Offline

#3 2008-10-14 00:33:21

whargoul
Member
From: Odense, Denmark
Registered: 2005-04-04
Posts: 546

Re: Running a script when switching battery and ac automaticly?

$ pacman -S laptop-mode-tools

Last edited by whargoul (2008-10-14 00:33:40)


Arch - It's something refreshing

Offline

#4 2008-10-14 03:01:50

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: Running a script when switching battery and ac automaticly?

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

#5 2008-10-14 19:14:02

tomdbike
Member
Registered: 2008-09-07
Posts: 25

Re: Running a script when switching battery and ac automaticly?

Profjim wrote:

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 smile

Offline

Board footer

Powered by FluxBB