ORIGINAL CODE - Doesn't include last 0 for 100%. Thanks to jwkrahn for the simpler and more precise code ^^ above#!/usr/bin/perl print '',( `acpi` =~ /(\d+)%/ )[ 0 ] // '??', "%";
#!/usr/bin/perl #battery.pl use strict; use warnings; use 5.012; my $battery_charge; $battery_charge = `acpi`; if($battery_charge =~ /\d{2}%/ ) { print "Battery: $&\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Laptop Battery Percentage
by jwkrahn (Abbot) on Aug 01, 2011 at 04:55 UTC | |
by naildownx (Beadle) on Aug 01, 2011 at 12:48 UTC | |
by naildownx (Beadle) on Aug 07, 2011 at 04:14 UTC | |
|
Re: Laptop Battery Percentage
by zentara (Cardinal) on Aug 01, 2011 at 13:18 UTC | |
by Tux (Canon) on Aug 01, 2011 at 17:28 UTC | |
by jimmy.tty (Scribe) on Aug 02, 2011 at 23:36 UTC | |
by strredwolf (Chaplain) on Aug 05, 2011 at 03:18 UTC | |
by Tux (Canon) on Aug 05, 2011 at 07:16 UTC |