Date: Fri, 02 Jul 2004 08:53:34 +1200 From: Drew Broadley <drew@corrupt.co.nz> To: acpi@freebsd.org, mobile@freebsd.org Subject: acpiexec - Run programs if on battery and/or ac power Message-ID: <40E479CE.7060203@corrupt.co.nz>
next in thread | raw e-mail | index | archive | help
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:anonymous@cvs.corrupt.co.nz:/public login <no password, just hit enter> $ cvs -d :pserver:anonymous@cvs.corrupt.co.nz:/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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40E479CE.7060203>