diff -Nru fdpowermon-1.19/debian/changelog fdpowermon-1.20/debian/changelog --- fdpowermon-1.19/debian/changelog 2019-12-11 07:00:46.000000000 +0000 +++ fdpowermon-1.20/debian/changelog 2022-03-23 12:19:12.000000000 +0000 @@ -1,3 +1,9 @@ +fdpowermon (1.20) unstable; urgency=medium + + * Handle a "Not charging" state. Closes: #1007702. + + -- Wouter Verhelst Wed, 23 Mar 2022 14:19:12 +0200 + fdpowermon (1.19) unstable; urgency=medium [ Wouter Verhelst ] @@ -7,7 +13,7 @@ * Bump debhelper from deprecated 7 to 12. * Change priority extra to priority optional. - -- Wouter Verhelst Wed, 11 Dec 2019 09:00:46 +0200 + -- Wouter Verhelst Thu, 11 Dec 2019 09:00:46 +0200 fdpowermon (1.18) unstable; urgency=medium diff -Nru fdpowermon-1.19/fdpowermon fdpowermon-1.20/fdpowermon --- fdpowermon-1.19/fdpowermon 2016-07-16 14:40:10.000000000 +0000 +++ fdpowermon-1.20/fdpowermon 2022-03-23 12:10:10.000000000 +0000 @@ -422,10 +422,12 @@ open my $acpi, "acpi -bi |"; while ($acpi_output = <$acpi>) { chomp $acpi_output; - if ($acpi_output =~ /^Battery (\d): ((Dis)?[Cc]harging|Unknown|Full), ((\d)+)%(, ([\d:]*))?/) { + if ($acpi_output =~ /^Battery (\d): ((Dis|Not )?[Cc]harging|Unknown|Full), ((\d)+)%(, ([\d:]*))?/) { $title_text .= ($found ? "\n" : "") . $acpi_output; $bat = $1; - $state = $2; + if(!defined($state) || ($state ne "Discharging" && $state ne "Charging")) { + $state = $2; + } $level = $4; if (defined($6)) { $remaining = $7; diff -Nru fdpowermon-1.19/fdpowermon.1 fdpowermon-1.20/fdpowermon.1 --- fdpowermon-1.19/fdpowermon.1 2016-07-16 14:40:38.000000000 +0000 +++ fdpowermon-1.20/fdpowermon.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -. ds C` -. ds C' -'br\} -.\" -.\" Escape single quotes in literal strings from groff's Unicode transform. -.ie \n(.g .ds Aq \(aq -.el .ds Aq ' -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.\" -.\" Avoid warning from groff about undefined register 'F'. -.de IX -.. -.nr rF 0 -.if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{ -. if \nF \{ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. if !\nF==2 \{ -. nr % 0 -. nr F 2 -. \} -. \} -.\} -.rr rF -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "FDPOWERMON 1" -.TH FDPOWERMON 1 "2016-06-27" "perl v5.22.2" "User Contributed Perl Documentation" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.if n .ad l -.nh -.SH "NAME" -fdpowermon \- add a battery level icon to a freedesktop.org\-compliant system tray -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -fdpowermon -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -This program allows one to display a \*(L"battery level\*(R" icon in any -freedesktop.org\-compliant status area. It can be themed through either a -plain-text configuration file (\fI/etc/fdpowermon/theme.cfg\fR or -\&\fI\f(CI$XDG_CONFIG_DIR\fI/fdpowermon/theme.cfg\fR), or through a short perl script -(\fI/etc/fdpowermon/theme.pl\fR or \fI\f(CI$XDG_CONFIG_DIR\fI/fdpowermon/theme.pl\fR). -If \f(CW$XDG_CONFIG_DIR\fR is not set, \f(CW$HOME\fR/.config is used as a default. -.PP -The former is easier, as it doesn't require any scripting; and indeed -the default configuration is an example of such a plain-text theme. -However, the latter allows for more flexibility, as one can define -callbacks that should be run when the battery level reaches a certain -threshold. -.PP -Themes, whether perl themes or plain-text themes, are built through -\&'steps', which are defined in a single line. In a plain-text config -file, such a line looks like this: -.PP -.Vb 1 -\& discharging = 2:missing.png:low.png, 10:low.png, 100:full.png -.Ve -.PP -This defines three steps. The highest step shows \*(L"full.png\*(R" when the -battery level is between 11% and 100% (inclusive); the second step shows -\&\*(L"low.png\*(R" when the battery level is between 3% and 10% (inclusive); and -the third step will alternate between \*(L"missing.png\*(R" and \*(L"low.png\*(R" on -three-second intervals, when the battery is between 0% and 2%. -.PP -Since the line starts with \*(L"discharging\*(R", 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: -.PP -.Vb 1 -\& charging = 0:empty\-charging.png, 10:low\-charging.png, 100: full\-charging.png -.Ve -.PP -this will show \*(L"empty\-charging.png\*(R" when the battery is at 0% (exactly), -\&\*(L"low\-charging.png\*(R" between 1% and 10% (inclusive), and \*(L"full\-charging.png\*(R" -at 11% and above. -.PP -Note that ordering is significant: steps should be defined from low to -high. -.PP -To complete the theme configuration, we must add a few more items: -.PP -.Vb 5 -\& [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 -.Ve -.PP -This defines a theme called \*(L"mytheme\*(R" which has three steps, and will -look for images in the directory -\&\*(L"/home/wouter/.fdpowermon/mytheme\-icons\*(R". 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. -.PP -Note that ordering is significant here, too; the \*(L"steps\*(R" line should -appear before any \*(L"charging\*(R" or \*(L"discharging\*(R" lines (this was not the -case in fdpowermon 1.7 or below). -.PP -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. -.PP -Perl theme config files can use fdpowermon::theme::make_default to -change the default theme. -.SH "PERL API" -.IX Header "PERL API" -.ie n .SS "@warnings" -.el .SS "\f(CW@warnings\fP" -.IX Subsection "@warnings" -The \f(CW@fdpowermon::theme::warnings\fR 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. -.PP -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). -.PP -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. -.ie n .SS "$use_notify" -.el .SS "\f(CW$use_notify\fP" -.IX Subsection "$use_notify" -The variable \f(CW$fdpowermon::theme::use_notify\fR 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). -.PP -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. -.PP -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! -.SS "new" -.IX Subsection "new" -Create a new fdpowermon theme. Returns a blessed reference; e.g., -.PP -.Vb 1 -\& my $theme = new fdpowermon::theme; -.Ve -.ie n .SS "$theme\->set_stepcount($count)" -.el .SS "\f(CW$theme\fP\->set_stepcount($count)" -.IX Subsection "$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 \*(L"charging\*(R" and the -\&\*(L"discharging\*(R" direction. -.PP -Should be called before calling set_charging, set_discharging, or -parse_step. -.ie n .SS "$theme\->set_dir($dir)" -.el .SS "\f(CW$theme\fP\->set_dir($dir)" -.IX Subsection "$theme->set_dir($dir)" -Set the base directory used for icon file names. -.ie n .SS "$theme\->set_charging(\e@elements)" -.el .SS "\f(CW$theme\fP\->set_charging(\e@elements)" -.IX Subsection "$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. -.ie n .SS "$theme\->set_discharging(\e@elements)" -.el .SS "\f(CW$theme\fP\->set_discharging(\e@elements)" -.IX Subsection "$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. -.ie n .SS "$theme\->parse_step($defs)" -.el .SS "\f(CW$theme\fP\->parse_step($defs)" -.IX Subsection "$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 \f(CW\*(C` charging = \*(C'\fR or -\&\f(CW\*(C` discharging = \*(C'\fR. -.PP -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. -.ie n .SS "$theme\->set_event($step, \e&callback, 'd')" -.el .SS "\f(CW$theme\fP\->set_event($step, \e&callback, 'd')" -.IX Subsection "$theme->set_event($step, &callback, 'd')" -Update the theme so the sub 'callback' is executed when we're discharging -and we reach \f(CW$step\fR for the first time. To set an event when charging -instead, pass a 'c' as the third argument. -.PP -Note that the steps are arrays, and are therefore 0\-based; the lowest-numbered -items are the lowest-level steps. -.PP -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 \s-1ACPI\s0 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. -.ie n .SS "$theme\->register($name)" -.el .SS "\f(CW$theme\fP\->register($name)" -.IX Subsection "$theme->register($name)" -Registers a theme under a given name. If a theme already exists under -that name, it is replaced. -.SS "make_default($name)" -.IX Subsection "make_default($name)" -Makes a theme with a given name be the default theme. -.SS "get_theme($name)" -.IX Subsection "get_theme($name)" -Looks up a theme with the given name; e.g., -.PP -.Vb 1 -\& my $theme = fdpowermon::theme::get_theme("default"); -.Ve -.SS "warning($message)" -.IX Subsection "warning($message)" -Produce a warning, either using libnotify, or using a dialog box: -.PP -.Vb 1 -\& fdpowermon::theme::warning($message); -.Ve -.PP -See the documentation on \f(CW$fdpowermon::theme::use_notify\fR above for -details on which implementation is chosen. -.SH "EXAMPLES" -.IX Header "EXAMPLES" -For a full .cfg theme example, look above. -.PP -To construct the same theme fully from perl, you'd do something like this: -.PP -.Vb 5 -\& 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")); -.Ve -.PP -(note, as a perl theme, this would go in theme.pl, not theme.cfg; see -above for possible locations for perl themes) -.PP -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: -.PP -.Vb 3 -\& sub suspend { -\& system("sudo pm\-suspend"); -\& } -\& -\& my $theme = fdpowermon::theme::get_theme("mytheme"); -\& $theme\->set_event(0, \e&suspend, \*(Aqd\*(Aq); -.Ve -.PP -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 \*(L"pm-suspend\*(R" program, with sudo, to -suspend the system.