FDPOWERMON(1)
β¨ FDPOWERMON β¨
okay bestie, so fdpowermon is a thing from the User Contributed Perl Documentation corner of the manual-verse, and honestly? it's giving tiny-but-mighty. π
πΈ NAME πΈ
fdpowermon β it slaps a battery level icon into a freedesktop.org-compliant system tray. that's the whole vibe. πβ¨
π SYNOPSIS π
fdpowermon
like. that's it. no flags, no drama, just run it. π
π¦ DESCRIPTION π¦
okay so this program lets you display a "battery level" icon in any freedesktop.org-compliant status area. no cap. π«Ά
and you can theme it two ways:
- through a plain-text configuration file:
/etc/fdpowermon/theme.cfgor$XDG_CONFIG_DIR/fdpowermon/theme.cfg - or through a short perl script:
/etc/fdpowermon/theme.plor$XDG_CONFIG_DIR/fdpowermon/theme.pl
and if $XDG_CONFIG_DIR isn't set, then $HOME/.config is used as the default. periodt.
the plain-text one is easier β it doesn't require any scripting at all, and in fact the default configuration is literally an example of such a plain-text theme. iconic. the perl one gives you more flexibility though, because you can define callbacks that should run when the battery level reaches a certain threshold. π₯
themes β whether they're perl themes or plain-text themes β are built through 'steps', and each step is defined in a single line. in a plain-text config file, such a line looks like this:
discharging = 2:missing.png:low.png, 10:low.png, 100:full.png
this defines three steps:
- the highest step shows
full.pngwhen the battery level is between 11% and 100% (inclusive) - the second step shows
low.pngwhen the battery level is between 3% and 10% (inclusive) - the third step will alternate between
missing.pngandlow.pngon three-second intervals, when the battery is between 0% and 2%
and since the line starts with discharging, these steps are used when the system is running on battery power. π
a similar line of steps could be defined for when the battery is charging:
charging = 0:empty-charging.png, 10:low-charging.png, 100: full-charging.png
this will show:
empty-charging.pngwhen the battery is at 0% (exactly)low-charging.pngbetween 1% and 10% (inclusive)full-charging.pngat 11% and above
note that ordering is significant: steps should be defined from low to high. don't do it backwards bestie, it will not slay. π
to complete the theme configuration, we must add a few more items:
[mytheme]
steps = 3
dir = /home/wouter/.fdpowermon/mytheme-icons
charging = 0:empty-charging.png, 10:low-charging.png, 100: full-charging.png
discharging = 2:missing.png:low.png, 10:low.png, 100:full.png
this defines a theme called "mytheme" which has three steps, and will look for images in the directory "/home/wouter/.fdpowermon/mytheme-icons". π
it is not possible to define a theme which has a different number of steps for the charging phase than it does for the discharging phase. if you want that, just define (an) extra step(s) for the phase that you would like to have less steps, which has the same icon as the step above or below. easy workaround, ate. π
note that ordering is significant here, too β the"steps"line should appear before any"charging"or"discharging"lines (this was not the case in fdpowermon 1.7 or below). π¨
if more than one theme is configured, fdpowermon will, by default, use the last theme defined in the per-user configuration, or (if no per-user configuration file exists) the last theme defined in the system-wide configuration. π§
perl theme config files can use fdpowermon::theme::make_default to change the default theme.
π PERL API π
π @warnings π
the @fdpowermon::theme::warnings array can be used to specify at which levels fdpowermon should issue a standard warning. the default is (10, 5, 1), which means to issue a warning at a level of 10%, 5%, and 1%.
note that if the battery runs flat at a particularly fast pace, the level may have reduced even further than that before the warning is issued; also, fdpowermon will issue a warning immediately when power is removed from the machine and the power is below the first level. π³
to make fdpowermon always issue a warning when power is removed, set this to something like (100, 10, 5, 1). to make fdpowermon issue warnings at 20%, 10%, and 5%, set this to (20, 10, 5).
note that it is not possible to change the text of the warning. if you want that, see the fdpowermon::theme::warning sub, and use an event.
π $use_notify π
the variable $fdpowermon::theme::use_notify can be used to decide whether to use a libnotify message (if set to a nonzero value), or a dialog window (if set to a value which evaluates to zero).
the default is to use libnotify if the libnotify Glib introspection data is installed, or a dialog box if not. because dialog boxes can steal the focus and therefore wreak havoc with the user's work, using libnotify is strongly recommended by the author. π«Ά
note that if you set the variable to nonzero explicitly, then the test whether or not the Glib introspection data is installed will be ignored. make sure it's available in that case! bestie please. π
π new π
create a new fdpowermon theme. returns a blessed reference; e.g.,
my $theme = new fdpowermon::theme;
π $theme->set_stepcount($count) π
set the number of steps in the theme. note that an fdpowermon theme must have an equal number of steps in both the "charging" and the "discharging" direction. π
should be called before calling set_charging, set_discharging, or parse_step. (order matters, always.)
π $theme->set_dir($dir) π
set the base directory used for icon file names. π
π $theme->set_charging(@elements) π
set the icons that should be shown when the battery is charging. the argument should be created by way of the parse_step method.
π $theme->set_discharging(@elements) π
set the icons that should be shown when the battery is discharging. the argument should be created by way of the parse_step method.
π $theme->parse_step($defs) π
parses the given string into something that can be passed on to set_charging or set_discharging. the definitions should be in the steps format, described above, without the leading " charging = " or " discharging = ".
while this method returns an arrayref that can be inspected and (probably) modified, themes that want to be forward-compatible should treat it as an opaque data structure. don't peek behind the curtain, babe. π
π $theme->set_event($step, &callback, 'd') π
update the theme so the sub 'callback' is executed when we're discharging and we reach $step for the first time. to set an event when charging instead, pass a 'c' as the third argument.
note that the steps are arrays, and are therefore 0-based; the lowest-numbered items are the lowest-level steps. β
when the event triggers, the callback routine will be passed two arguments:
- the first is the current battery level (in percent)
- the second is a number denoting whether the battery is currently charging (
1) or discharging (0)
in case the parsing of the ACPI command fails, however, the second argument may be undef; you should prepare for this possibility. π note that fdpowermon itself handles that case by assuming the battery is charging; you may or may not wish to do the same.
π $theme->register($name) π
registers a theme under a given name. if a theme already exists under that name, it is replaced. no hesitation, no mercy. π
π make_default($name) π
makes a theme with a given name be the default theme. π
π get_theme($name) π
looks up a theme with the given name; e.g.,
my $theme = fdpowermon::theme::get_theme("default");
π warning($message) π
produce a warning, either using libnotify, or using a dialog box:
fdpowermon::theme::warning($message);
see the documentation on $fdpowermon::theme::use_notify above for details on which implementation is chosen.
π EXAMPLES π
for a full .cfg theme example, look above. β¬οΈ
to construct the same theme fully from perl, you'd do something like this:
my $theme = new fdpowermon::theme;
$theme->set_stepcount(3);
$theme->set_dir("/home/wouter/.fdpowermon/mytheme-icons");
$theme->set_charging($theme->parse_step("0:empty-charging.png, 10:low-charging.png, 100: full-charging.png"));
$theme->set_discharging($theme->parse_step("2:missing.png:low.png, 10:low.png, 100:full.png"));
(note, as a perl theme, this would go in theme.pl, not theme.cfg; see above for possible locations for perl themes)
however, unless you want to build the theme dynamically, doing it this way is not recommended. instead, you would build the theme from a .cfg file, and possibly modify it from perl. let's say you wish to add an event to suspend the system when the power gets low; in that case, you'd do something like this:
sub suspend {
system("sudo pm-suspend");
}
my $theme = fdpowermon::theme::get_theme("mytheme");
$theme->set_event(0, \&suspend, 'd');
this would call the 'suspend' sub when the battery is discharging and we reach the lowest step (in the above example, that would be when the battery reaches 10%; you might want to do that somewhat later π). this 'suspend' sub simply calls the "pm-suspend" program, with sudo, to suspend the system. β¨
and that's the whole page bestie!! written up in perl v5.40.1, dated 2025-12-11, from the User Contributed Perl Documentation era. go forth and monitor those batteries, you absolute icon. πππ«Ά
π¦ where this page comes from
- ubuntu resolute: fdpowermon 1.20build1
- ubuntu stonking: fdpowermon 1.20build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms