LXDE – How to Change Battery Icon in the Panel

iconslxdeopenbox

I have installed LXDE on Debian (LXDE metapackage). I have also installed some additional themes and icons, but when I chage the icons, the battery icon in the task bar stays the same (basically just an ugly green rectange, that does not look anything like a battery).

This is how it currently looks like:

enter image description here

UPDATE:

I have installed nice icon set, where there are icons of battery in several stages of charging/discharging. I am wondering whether it is possible to change my lxpanel configuration, so that it displays icons instead of the green rectangle.

Following is the relevant code from my ~/.config/lxpanel/LXDE/panels/panel

Plugin {
    type = batt
    Config {
        HideIfNoBattery=0
        AlarmCommand=xmessage Battery low
        AlarmTime=5
        BackgroundColor=black
        BorderWidth=1
        ChargingColor1=#28f200
        ChargingColor2=#22cc00
        DischargingColor1=#ffee00
        DischargingColor2=#d9ca00
        Size=12
    }
}

Best Answer

The applet for the Battery Monitor plugin does not use a simple icon. It draws a 2D vector graphic using the Cairo library. You can only edit the panel item's appearance within the limits provided by the plugin, which does not currently include an option for replacing it with an icon.

It's normal that themes do not affect this panel item's appearance because, afaik, editing the package's source at lxpanel-<version>/plugins/batt/batt.c and installing your new custom version is the only way to make dramatic changes beyond what the plugin's settings currently allow for. Alternatively, you would have to find a different battery monitor plugin or write your own if you want to see any major changes here.

Editing Battery Monitor's Appearance Settings:
Editing the file ~/config/lxpanel/LXDE/panels/panel.config directly does not immediately update or refresh the appearance of the battery monitor panel item.

Instead, right-click the battery monitor applet and select "Battery Monitor" Settings (where you'll notice it's actually two ugly green rectangles). The plugin should apply the new configuration and update the display of the widget upon closing this window.

Battery Monitor settings

Using a Different Plugin:
Some plugins, such as the GNOME Power Manager, can be themed by use of static icon images. From the officieal GNOME Power Manager project site:

The notification icon can display a device in the tray. The icons can be themed with custom icons for each theme, or fallback to a standard default.

This should allow you to use your theme's icons. Install it with apt-get.
apt-get install gnome-power-manager

You may or may not need to manually add @gnome-power-manager to your /etc/xdg/lxsession/LXDE/autostart file. If you have any problems, please create a new question that pertains to Gnome Power Manager specifically.

Writing your own battery monitor plugin:
The details of writing your own plugin are beyond the scope of this question, but for those interested and willing to code a bit, see How to write plugins for LXPanel - LXDE.org and Debian - How to monitor battery capacity. As mentioned before, the battery monitor plugin included with the lxde-common package relies on the Cairo library. A good tutorial for working with that can be found at Cairo graphics tutorial.


The bounty requests: "Looking for an answer drawing from credible and/or official sources."

I am looking at the source for this plugin from lxpanel-0.7.1 downloaded at LXDE - Lightweight X Desktop Environment - Browse /LXPanel (desktop panel) at SourceForge.net

Related Question