[bluetooth_info.pl]: print battery percentage only if defined
Also add keyboard & mouse icons
This commit is contained in:
@ -9,12 +9,15 @@ my $output = `bluetoothctl info` or die("disconnected\n");
|
||||
my $mac_address = ($output =~ /^Device\s+(\S+)/) ? "$1" : die("disconnected\n");
|
||||
my $device_name = ($output =~ /Name:\s+(.*)/) ? "$1" : "unknown";
|
||||
my $icon = ($output =~ /Icon:\s+(.*)/) ? "$1" : "";
|
||||
my $battery_percentage = ($output =~ /Battery Percentage:\s+\S+\s\(([0-9]+)\)/) ? "$1" : "?";
|
||||
my $battery_percentage = ($output =~ /Battery Percentage:\s+\S+\s\(([0-9]+)\)/) ? "$1" : undef;
|
||||
|
||||
my %icons = (
|
||||
"audio-headphones" => "",
|
||||
"audio-headset" => ""
|
||||
"audio-headset" => "",
|
||||
"input-keyboard" => "",
|
||||
"input-mouse" => ""
|
||||
);
|
||||
|
||||
printf("$icons{$icon} ") if exists $icons{$icon};
|
||||
printf("$device_name $battery_percentage%%");
|
||||
printf("$device_name");
|
||||
printf(" $battery_percentage%%") if defined $battery_percentage;
|
||||
|
Reference in New Issue
Block a user