8 my $path = '/sys/class/power_supply/BAT0/uevent';
10 # No battery available.
15 my $screen_mode = (defined $ARGV[0] and $ARGV[0] eq '-s');
19 open my $file, '<', $path;
21 /^POWER_SUPPLY_([A-Z_]+)=(.+)$/;
26 my $charge = int($battery{CHARGE_NOW} / $battery{CHARGE_FULL} * 100);
28 # GNU screen mode with colors: 0-20 red, 20-40 yellow, 40-100 green.
33 } elsif ($charge < 40) {
39 print "\005{+$color}$charge%\005{-}\n";