PDA

View Full Version : [ubuntu] Using power status trigger



bipin.nag
January 18th, 2012, 06:40 PM
I wanted to use the power status of my laptop in my programs
like how do I use power status to trigger some actions

For example
if power status changes from charging to battery start/stop a service
or if battery power falls below some percentage sleep

NOT that i want to make some power manager for my system
just take the inputs from the power status to do stuff in form of bash scripts

SteveDee
January 18th, 2012, 06:56 PM
I wanted to use the power status of my laptop in my programs...

Well you could look at: /proc/acpi/ac_adapter/AC/state
which may look something like this:-


state: off-line

...when on battery, or this:-


state: on-line

...when running from the charger.

bipin.nag
January 19th, 2012, 10:42 AM
Thanks that is what I was looking for