Package: fdpowermon Version: 1.19 Severity: important Tags: patch Dear Wouter,
With my Thinkpad X270 (having two batteries) I noted, that fdpowermon sometimes ignores one of the batteries and/or throws the following error: Use of uninitialized value $level in multiplication (*) at /bin/fdpowermon line 439, <$acpi> line 2. Digging a little deeper, I found out, that this is triggered by "acpi -bi" sometimes showing the state "Not charging" on my system, which triggers the problem. Here are some example outputs of "acpi -bi", that failed: Battery 0: Not charging, 96% Battery 0: design capacity 1920 mAh, last full capacity 1478 mAh = 76% Battery 1: Discharging, 29%, 03:21:51 remaining Battery 1: design capacity 4432 mAh, last full capacity 3999 mAh = 90% Battery 0: Discharging, 56%, 02:19:38 remaining Battery 0: design capacity 2061 mAh, last full capacity 1587 mAh = 77% Battery 1: Not charging, 5% Battery 1: design capacity 4571 mAh, last full capacity 4125 mAh = 90% Battery 0: Charging, 6%, 00:45:14 until charged Battery 0: design capacity 1997 mAh, last full capacity 1537 mAh = 76% Battery 1: Not charging, 5% Battery 1: design capacity 4571 mAh, last full capacity 4125 mAh = 90% Battery 0: Not charging, 79% Battery 0: design capacity 1955 mAh, last full capacity 1505 mAh = 76% Battery 1: Charging, 99%, 00:03:22 until charged Battery 1: design capacity 3831 mAh, last full capacity 3457 mAh = 90% The attached minimal patch should work around this issue by simply allowing the state "Not charging". Greetings Roland -- System Information: Debian Release: 11.2 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-12-amd64 (SMP w/4 CPU threads) Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=de_DE.utf-8, LC_CTYPE=de_DE.utf-8 (charmap=UTF-8), LANGUAGE=en_US:en Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages fdpowermon depends on: ii acpi 1.7-1.1 ii fdpowermon-icons 1.19 ii libgtk3-perl 0.038-1 ii perl 5.32.1-4+deb11u2 Versions of packages fdpowermon recommends: ii gir1.2-notify-0.7 0.7.9-3 fdpowermon suggests no packages. -- no debconf information
--- a/fdpowermon +++ b/fdpowermon @@ -422,7 +422,7 @@ sub checklevels { 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;
signature.asc
Description: PGP signature