Tuesday, March 1, 2011

Getting Conky To Display Your iBook or Powerbook Battery

I couldn't figure out how to get Conky, a lightweight system monitor for Linux, to display the battery charge on the G3 iBook given that most of the example conkyrc files I saw were for the Intel architecture and used ACPI or APM for power management and monitoring, neither of which is utilized on PPC machines. So off to Google I went.

Long story short, if I knew to google "conky pb_battery" it would have saved me a whole lot of time. It turns out you need to insert the variable pb_battery in your conkyrc file like this: under the TEXT section at the bottom insert {pb_battery percent} in the appropriate spot accompanied by whatever text you want displayed with it, like "Battery:" so that it displays out "Battery: 93%" or somesuch.

percent isn't the only item within the variable you can display. There's also status and time. status shows whether the battery is "fully charged, charging, discharging, or absent (running on AC)."* time shows "the time remaining until the battery will be fully charged or discharged at current rate."* Note that under percent and time, nothing will be displayed if battery is fully charged or is running on AC power. Also note that you can only specify one item. Your variable must read either {pb_battery percent} or {pb_battery status} or {pb_battery time}.

Or if you want to do all this commando style, you can monitor your battery from the command line. Just type cat /proc/pmu/battery_0, and you'll get the output you want.

*Quotes taken from Conky's website.

One last note: the monospace font makes it look like there's a space between "{" and "pb_battery". There isn't. Just copy and paste for the right syntax.

2 comments:

  1. Could you copy and past your conkyrc file, I'm having a bit of trouble with the intel based ones on the web. For instance, Network up and down doesn't work and neither does cpu temperature. Cheers.

    ReplyDelete
  2. Sorry, I don't have conky currently. For network up and down, make sure the network interface in the conkyrc is the correct one, i.e. "eth0" or "eth1". On my iBook eth0 is the ethernet connection and eth1 is wireless. As for cpu temp, there's no acpi in PowerPC, so I think that's why it's not working. The only thing I really know is you can do "cat /proc/cpuinfo" and find all kinds of cpu info including temperature. Maybe there's a way to get conky to read that.

    ReplyDelete