From 9d27a1c0570a383e4b2c037d5120cab6eb0f1ca8 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 13 Jul 2024 04:24:36 +0100 Subject: [PATCH] Add bluetooth_info.pl --- bluetooth_info.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bluetooth_info.pl diff --git a/bluetooth_info.pl b/bluetooth_info.pl new file mode 100755 index 0000000..b1eb644 --- /dev/null +++ b/bluetooth_info.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl -l + +use strict; +use warnings; + +my $output = `bluetoothctl info` or die; + +my $mac_address = $1 if ($output =~ /^Device\s+(\S+)/) or die("N/A\n"); +my $device_name = $1 if ($output =~ /Name:\s+(.*)/); +my $icon = $1 if ($output =~ /Icon:\s+(.*)/); +my $battery_percentage = $1 if ($output =~ /Battery Percentage:\s+\S+\s\(([0-9]+)\)/); + +if ($icon eq "audio-headphones") { + printf(" "); +} +printf("$device_name $battery_percentage%%");