From b3b0f9b6632b5f133fb37973e0ef19311d0f3a60 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 19 Feb 2025 16:21:39 +0000 Subject: [PATCH] [bluetooth_info.pl]: print battery percentage only if defined Also add keyboard & mouse icons --- src/bluetooth_info.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bluetooth_info.pl b/src/bluetooth_info.pl index bcf564e..4fc088e 100755 --- a/src/bluetooth_info.pl +++ b/src/bluetooth_info.pl @@ -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("$icons{$icon} ") if exists $icons{$icon}; +printf("$device_name"); +printf(" $battery_percentage%%") if defined $battery_percentage;