From owner-freebsd-mobile@FreeBSD.ORG Thu Jul 1 20:56:32 2004 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3802F16A4CF for ; Thu, 1 Jul 2004 20:56:32 +0000 (GMT) Received: from mail.corrupt.co.nz (222-152-9-229.jetstream.xtra.co.nz [222.152.9.229]) by mx1.FreeBSD.org (Postfix) with SMTP id A504243D2D for ; Thu, 1 Jul 2004 20:56:29 +0000 (GMT) (envelope-from drew@corrupt.co.nz) Received: (qmail 87372 invoked by uid 1011); 1 Jul 2004 20:55:06 -0000 Received: from drew@corrupt.co.nz by tweety.lan.corrupt.co.nz by uid 1009 with qmail-scanner-1.22 Clear:RC:0(10.10.69.146):SA:0(0.0/3.8):. Processed in 5.314191 secs); 01 Jul 2004 20:55:06 -0000 X-Spam-Status: No, hits=0.0 required=3.8 Received: from unknown (HELO ?10.10.69.146?) (drew@corrupt.co.nz@10.10.69.146) by mail.corrupt.co.nz with SMTP; 1 Jul 2004 20:55:00 -0000 Message-ID: <40E479CE.7060203@corrupt.co.nz> Date: Fri, 02 Jul 2004 08:53:34 +1200 From: Drew Broadley User-Agent: Mozilla Thunderbird 0.6 (X11/20040606) X-Accept-Language: en-us, en MIME-Version: 1.0 To: acpi@freebsd.org, mobile@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: acpiexec - Run programs if on battery and/or ac power X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2004 20:56:32 -0000 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 $ 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