]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - bin/battery.pl
bin/battery.pl: Handle new keys ENERGY_NOW and ENERGY_FULL.
[config/dotfiles.git] / bin / battery.pl
index 41956ac43fb431dd9862d45a08e1a38ed5e56882..0bdaae04c1d8829a33a0edaf2e8a4fb709ae5289 100755 (executable)
@@ -37,7 +37,13 @@ while (<$file>) {
     /^POWER_SUPPLY_([A-Z_]+)=(.+)$/;
     $battery{$1} = $2;
 }
-close $file;
+close $file or die $!;
+
+# New names ...
+if (defined $battery{ENERGY_NOW}) {
+    $battery{CHARGE_NOW}  = $battery{ENERGY_NOW};
+    $battery{CHARGE_FULL} = $battery{ENERGY_FULL};
+}
 
 my $charge = int($battery{CHARGE_NOW} / $battery{CHARGE_FULL} * 100);