summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbattery34
1 files changed, 20 insertions, 14 deletions
diff --git a/battery b/battery
index 589c228..a6de32b 100755
--- a/battery
+++ b/battery
@@ -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;
}