Wednesday, April 22, 2015

An Applet a Day Keeps the Doctor Away

I'm subscribed to the Debian PPC mailing list (if you aren't yet, you definitely should be!) and recently read about a "new" Gnome (both a gtk2 and 3 version) battery menu applet for our PowerPC portables as well as a version of it that was ported to C.

You can read more about the applet here and the C code can be downloaded from Github here.  The version written in C is actually relatively straightforward code to read through. As another user mentioned, it is kind of cool to see how a menu applet can actually be written and works.

Once you've downloaded the zip file, unpack it by running the following command inside the folder where you downloaded the zip, such as your user profile's Downloads folder.
unzip mac-battery-applet-master-master.zip

Change directories into the unzipped folder and run:
make install

This should copy the Linux PPC executable to your /usr/local/bin folder so go ahead and type mac- and it should auto-complete the command to mac-battery-applet for you. Hit enter and you should see a small battery icon appear in your task bar/panel as can be seen from the screen shot below.


Hovering your mouse over the icon brings up a small pop-up of sorts that gives you the remaining estimated battery capacity and number of minutes of runtime until the battery is depleted.

Of course, you don't want to manually run this every time you reboot or power on your PPC laptop, so go ahead and add it to the necessary startup configuration for your desktop environment.  For LXDE, I added the line @mac-battery-applet to my autostart file located at /etc/xdg/lxsession/LXDE.

There are numerous battery icon files for showing the percentages of remaining capacity and they exist for both when the laptop is on battery power and when it is charging.  When the laptop is plugged in and charging a small + symbol appears on the upper right hand side.  A function called build_icon_file_name creates the necessary filename and it uses the code in files.c to construct the path for the corresponding file for that % of battery based on the built filename.   There is a lot more to it all, but pretty cool I think overall.  Some might prefer to have more granular results, but I think the 10% increment icons are an okay trade-off.  Ideally, I might do 5% increments, but that could become quite tedious when creating the icon files.  

Reading through the README, it says there is currently no Debian package for this applet, but the author states he would be more than willing to let someone else tackle that project. I've personally never done this, but perhaps it would be worth it to finally use it as a chance to learn all that does go into building a Debian package if it is even that much?  I've heard arguments on both sides.

Anyways, there is much more valuable information in the links I provided, including possible future updates to the applet, such as custom icon themes, so I encourage you to check those out. Did I mention this was done on a recently purchased 1.42 GHz G4 iBook? Yeah, I am stoked. I'm almost done with the memory upgrade and tests on the G4 QS.  Look for it in the next couple of days.

No comments:

Post a Comment