1

i3status-anyevent: upower does not provide "time to" value if battery fully chrged

This commit is contained in:
Sergei Fedosov
2021-02-20 18:36:09 +03:00
parent 1cb4103dd6
commit 3a09fcf22f

View File

@@ -353,10 +353,11 @@ sub add_events () {
} }
} }
unless (defined $time_to && defined $percentage && defined $state) { unless (defined $percentage && defined $state) {
return; return;
} }
if (defined $time_to) {
chomp $time_to; chomp $time_to;
if (substr ($time_to, -7) eq 'minutes') { if (substr ($time_to, -7) eq 'minutes') {
@@ -370,6 +371,10 @@ sub add_events () {
} }
$time_to = sprintf '%02d:%02d', $hours, $minutes; $time_to = sprintf '%02d:%02d', $hours, $minutes;
} else {
$time_to = "00:00";
}
$charge = sprintf '⚡ %s %s %s', $percentage, $state, $time_to; $charge = sprintf '⚡ %s %s %s', $percentage, $state, $time_to;
} }
); );