onBatteryPower

Richard Hughes hughsient at gmail.com
Wed Oct 26 09:55:45 PDT 2005


On Wed, 2005-10-26 at 12:36 -0400, David Zeuthen wrote:
>         [davidz at daxter ~]$ hal-find-by-capability --capability
>         ac_adapter
>         /org/freedesktop/Hal/devices/acpi_AC

So we could add something like this:

acad=`hal-find-by-capability --capability ac_adapter`
if [ $acad ] ; then
	onac=`hal-get-property --udi=$acad --key=ac_adapter.present`
	if [ "x$onac" == "xfalse" ] ; then
		echo "On battery power, aborting"
		exit 1
		fi
	fi

at the top of a typical cron script, say for instance:

* makewhatis
* prelink
* rpm
* slocate
* yum

So these don't get invoked when on battery.

What do you think?

Richard.





More information about the hal mailing list