Display battery charge value with LXDE and lxpanel - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: Pinebook (https://forum.pine64.org/forumdisplay.php?fid=76) +--- Forum: Linux on Pinebook (https://forum.pine64.org/forumdisplay.php?fid=79) +--- Thread: Display battery charge value with LXDE and lxpanel (/showthread.php?tid=7586) |
Display battery charge value with LXDE and lxpanel - wlad - 06-11-2019 In my opinion, Armbian with LXDE as window manager is a good fitting combination for the limited power of the Pinebook. LXDE provides only few visual effects, so the system can be used with acceptable performance. Unfortunately, I had an issue with the battery plugin of the lxpanel (the bar where all current windows/processes are stacked into). Indication: Battery plugin (batt) of lxpanel does not show the current "capacity" (charged value in percent) of Pinebook's battery. Instead, it displays "0% charged" and continuously fires the low-battery alarm. Reason: The integrated functionality of the battery plugin calculates the charged value by using the coulomb-based counters "charge_now" and "charge_full" (or alternatively "energy_now" and "energy_full"). These counters are usually provided by the power management unit's Linux kernel module. The kernel module (axp20x) for the AXP803 power management unit of the Pinebook does not provide "charge_now" and "charge_full" information. Instead, a percentage value for the current charge is provided as "capacity" (try 'cat /sys/class/power_supply/axp20x-battery/capacity'). Solution: I have changed the source code for the batt plugin with respect to the above mentioned reasons. Now, the percentage value is directly read from the corresponding sysfs file and not longer calculated indirectly. The original code (lxpanel version 0.10.0) that you can find in 'lxpanel-0.10.0/plugins/batt/batt_sys.c' looked like this: Code: battery* battery_update(battery *b) { This code has been changed to the following: Code: battery* battery_update(battery *b) { As this requires a new function for reading the numerical value as provided by '/sys/class/power_supply/axp20x-battery/capacity', I introduced the following function which was inserted below the existing function "static gint get_gint_from_infofile(battery *b, gchar *sys_file)" in the same source code file "batt_sys.c": Code: /* get_norm_gint_from_infofile(): The most time consuming part of this change was building the plugin's shared library file 'batt.so' because of all the required dependencies. But finally, it worked and I could replace the original file in '/usr/lib/aarch64-linux-gnu/lxpanel/plugins/'. The charge indicator now works as it should (except that I see no practical way how to predict the remaining power-on time). I provide to you my build of 'batt.so' here (together with the changed 'batt_sys.c'), so that you do not need to build it by yourself: lxde-lxpanel_batt-plugin.zip (Size: 39.15 KB / Downloads: 484) I use it on Armbian 5.86 Debian stretch with LXDE 9.9 and lxpanel version 0.9.3. It may also work with other versions of LXDE/lxpanel and in combination with different Armbian versions. Please post your message on whether it worked for you by mentioning your system configuration. Thanks! RE: Display battery charge value with LXDE and lxpanel - pnts-se - 12-04-2019 thanks for this pos Wlad! I trid to get it to work on a pinebook pro with the bionic lxde build but was not succesfull. My lxpanel library was located in /usr/lib/arm-linux-gnueabihf/ and not in /usr/lib/aarch64-linux-gnu/ as in your case. I'm a beginner but I guess it's because you're running armbian and I'm bionic. I also lacked the /batt/ folder mentioned in the original post. After some time I gave up and installed fce4-power-manager, xfce4-panel, and xfce4-goodies as mentioned in this thread and now the battery monitor is working, although I had to change panel in LXDE. https://forum.pine64.org/showthread.php?tid=6825&highlight=tips+tricks+bionic+LXDE+image edit: I celebrated too soon. It doesn't work. |