|
From: Philipp H. <ph...@ph...> - 2012-09-16 09:58:59
|
Hi,
sorry for not reacting to your message any earlier.
Unfortunately it seems to be a bit more difficult to write a good battery
script as there are several different conventions for the
/sys/class/power_supply/BAT* directories. For example on my system there is no
energy_now or energy_full file, which are the ones your script is trying to
read (and the same comment also applies to your patch[1] to
statusd_linuxbatt). Instead I have charge_now and charge_full files. Some
discussion[2] I've found via Google seems to indicate that there are even more
possibilities and that they all use different units. The acpi program is able
to handle these cases and so its source[3] is a good way to learn how to do
this correctly. I don't know how other window managers handle this, but that
might also be worth a look.
In the end, I don't feel like it is worth reimplementing all of this in Lua,
but of course that's just my personal opinion. I've long ditched all the
battery status indicators and now simply use the statusd_exec script to
periodically execute acpi -b. In detail, my configuration looks as follows. In
my template, I have an entry "%exec_acpi". In the
"mod_statusbar.launch_statusd" table I then have the following entry.
exec = {
acpi = {
program = 'acpi -b | cut -d\' \' -f3- | tr "\n" " "',
hint_regexp = {
critical = '^Discharging, 1?[0-9]%%',
},
retry_delay = 5 * 1000,
},
},
It gives me the current battery level in percent and the remaining time or the
time until fully charged, depending on whether I'm on AC or not. And if the
level is below 20 %, the output is colored in red.
I don't know if this would suit your needs. If you want greater flexibility,
maybe adapting your script to retrieve the values from the acpi program
instead of calculating them by hand might be a good solution? Including the
remaining time would then certainly also be very interesting. What do you
think?
Cheers,
Philipp
[1] http://sourceforge.net/tracker/?func=detail&aid=3551479&group_id=314802&atid=1324530
[2] https://github.com/denilsonsa/batterymon-clone/pull/3
[3] http://paste.debian.net/189979
|