BatTool Widget

This is a very simple widget, actually derived from sample Hello World widget, showing the status of your PowerBook battery, along with the number of recharge cycles already spent.

It has been recently adatped to run on Mac OSX version 10.4.9
It also runs on Intel MacBooks (tested on MacBook 2,1 Intel Core Duo, 2Ghz, Boot ROM version MB21.00A5.B00)




To install the widget, download it mount the image, and copy the BatTool.wdgt folder to your Library/Widgets directory, under your home page.

The only purpose of the widget is to show how a Unix command can be interfaced within a widget. Therefore no graphic frills, no redraw, no buttons, etc.
Also, no guarantee that it will work as expected everywhere, nor any responsibility for its usage.

The basic way to get the data shown in the widget is through an ioreg command processed through a pipe of unix filters (awk, grep, head). The pipe of Unix commands is executed in the widget through a widget.system() call, actually, which allows to access through Javascript (and therefore html) any kind of Unix command. The only care to be taken is to include the AllowSystem key in the Info.plist file, otherwise the system does not execute. Therefore the Info.plist must host an entry such as:

        < key > AllowSystem < /key >
        < true/ >
Thake into account that this key enables the widget to execute any Unix command. Therefore, a user having access to the Battool.html file may potentially destroy your Mac!

The data shown by this widget are taken directly, when the widget is opened only, are directly taken from the output of the ioreg -w0 -l command. In particular:

Enjoy.