Fix battery i3block
This commit is contained in:
@@ -24,12 +24,16 @@ my $short_text;
|
||||
my $bat_number = $ENV{BLOCK_INSTANCE} || 0;
|
||||
|
||||
# read the first line of the "acpi" command output
|
||||
open (ACPI, "acpi -b | grep 'Battery $bat_number' |") or die;
|
||||
open (ACPI, "acpi -b 2>/dev/null| grep 'Battery $bat_number' |") or die;
|
||||
$acpi = <ACPI>;
|
||||
close(ACPI);
|
||||
|
||||
# fail on unexpected output
|
||||
if ($acpi !~ /: (\w+), (\d+)%/) {
|
||||
if (not defined($acpi)) {
|
||||
# don't print anything to stderr if there is no battery
|
||||
exit(0);
|
||||
}
|
||||
elsif ($acpi !~ /: ([\w\s]+), (\d+)%/) {
|
||||
die "$acpi\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ INTERFACE="${BLOCK_INSTANCE:-wlan0}"
|
||||
QUALITY=$(sudo grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
|
||||
# echo $QUALITY
|
||||
W_inter=$(ip link | grep "[1-9]: wlp" | cut -d " " -f2 | tr -d ':')
|
||||
W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}')
|
||||
# W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user