diff options
author | dakkar <dakkar@thenautilus.net> | 2024-09-22 13:26:59 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2024-09-22 13:26:59 +0100 |
commit | 1395cafa45ff826145b8f3495d1277f352ff0e57 (patch) | |
tree | cb8a0f5f6c3cd8164054f969cc7abe5294c83794 | |
parent | narrower spacing because of nicer font (diff) | |
download | battery-1395cafa45ff826145b8f3495d1277f352ff0e57.tar.gz battery-1395cafa45ff826145b8f3495d1277f352ff0e57.tar.bz2 battery-1395cafa45ff826145b8f3495d1277f352ff0e57.zip |
more fun with symbols
-rwxr-xr-x | battery | 34 |
1 files changed, 20 insertions, 14 deletions
@@ -56,30 +56,36 @@ sub update { my $deriv = $bs->{power_now} // $bs->{current_now}; my $e=$now/$full; - my $txt=''; my $charging = lc($bs->{status}) eq 'charging'; my $is_full = lc($bs->{status}) eq 'full'; - if ($charging) { - $txt = "\x{1f50c}"; - } - elsif (!$is_full) { - $txt = "\x{1f50b}"; - } + my @symbols; + my $time_estimate=''; + my $percentage=sprintf '%.0f%%', 100*$e; + my $fraction=$e; + if ($deriv && !$charging) { my $t=$now/$deriv; my $tot=$full/$deriv; - $txt .= sprintf "%s/%s\x{2009}", + $time_estimate = sprintf "%s/%s", _format_time($t), - _format_time($tot); - $bar->set_fraction($t/$tot); + _format_time($tot); + $fraction= $t/$tot; } - else { - $bar->set_fraction($e); + + if ($charging) { + push @symbols, "\x{1f50c}"; + } + + if (!$is_full && $fraction > 0.5) { + push @symbols, "\x{1f50b}"; + } + elsif (!$is_full) { + push @symbols, "\x{1faab}"; } - $txt .= sprintf '%.0f%%', 100*$e; - $bar->set_text($txt); + $bar->set_fraction($fraction); + $bar->set_text(join "\x{2009}", grep { length } @symbols, $time_estimate, $percentage); return 1; } |