acpiexec - Run programs if on battery and/or ac power
Drew Broadley <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.mobile |
|---|---|
| Message-ID | <[email protected]> |
I had a problem, whenever I was on battery I had cronjobs that were
running every 5 minutes for various things (my ifconfigd script, which
is like "whereami" for FreeBSD) and it sucked my battery down 3 times+
faster.
So here is the solution, I have made a Perl script ( and additional Perl
Module BSD::Sysctl for other uses including this script) where you exec
your current commands passed as an argument or option to acpiexec. By
default, acpiexec will run the command when on AC power but NOT on battery.
Example of default usage:
*/60 * * * * /usr/sbin/acpiexec /home/drew/bin/xplanet_update 2>
/dev/null
Example of custom switches (run on battery AND ac power):
*/60 * * * * /usr/sbin/acpiexec --batt=y /home/drew/bin/ifconfig_update
Example of displaying your laptops current power status:
$ /usr/sbin/acpiexec status
acpiexec status
Default Settings:
Run Command if on Battery: no
Run Command if on AC Power: yes
Current Machine Status:
System is on Battery: no
System is on AC Power: yes
I hope some people find this helpful, I have placed it on my cvs server:
http://cvs.corrupt.co.nz/cgi-bin/cvsweb.cgi/acpiexec
or via pserver
$ cvs -d :pserver:[email protected]:/public login
<no password, just hit enter>
$ cvs -d :pserver:[email protected]:/public co acpiexec
You will need my BSD::Sysctl module located here:
http://cvs.corrupt.co.nz/cgi-bin/cvsweb.cgi/.pm/modules/BSD/Sysctl.pm
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-mobile
To unsubscribe, send any mail to "[email protected]"