Datastore & backup - request for help
bert at freudenbergs.de
Tue May 20 07:43:01 EDT 2008
On 20.05.2008, at 12:58, Bert Freudenberg wrote:
> On 20.05.2008, at 11:31, Martin Langhoff wrote:
>> On Tue, May 20, 2008 at 8:58 PM, Marco Pesenti Gritti
>> <mpgritti at gmail.com> wrote:
>>> But it works only on the XO.
>> Fair enough. Is there a portable (and lightweight) way of asking this
>> question from bash?
> battery=`hal-find-by-capability --capability battery`
> ac_adapter=`hal-find-by-capability --capability ac_adapter`
> finds you the HAL devices for the battery and the ac.
> lshal -lu $battery
> lshal -lu $ac_adapter
> shows the properties, then you can apply generic shell magic to test
> (like, grep for "ac_adapter.present = true"). Also, it gives you the
> sysfs path if you prefer that.
> Note that hal-find-* may return multiple items or none depending on
> the machine.
Ah, Marco rightly pointed out hal-get-property. Much easier that way:
hal-get-property --udi $battery --key battery.charge_level.percentage
hal-get-property --udi $ac_adapter --key ac_adapter.present
- Bert -
More information about the Devel