From bf6bf683cec73e07e02a70c980c4537cf4797cd1 Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Tue, 13 Sep 2022 09:20:38 +0000 Subject: [PATCH] Add sb-bluetooth script --- .local/bin/statusbar/sb-bluetooth | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .local/bin/statusbar/sb-bluetooth diff --git a/.local/bin/statusbar/sb-bluetooth b/.local/bin/statusbar/sb-bluetooth new file mode 100644 index 00000000..b818baa1 --- /dev/null +++ b/.local/bin/statusbar/sb-bluetooth @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Shows names of paired and connected bluetooth devices if bluetooth is on + +case $BLOCK_BUTTON in + 1) dmenubluetooth; pkill -RTMIN+2 dwmblocks ;; + 3) notify-send " Bluetooth module" "\- Shows paired devices. +- Click to configure bluetooth." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +if bluetoothctl show | grep -q 'Powered: yes'; then + printf '' + + i=0; while IFS= read -r device; do + if bluetoothctl info "$device" | grep -q 'Connected: yes'; then + device_alias=$(bluetoothctl info "$device" | grep 'Alias' | cut -d ' ' -f 2-) + + [ $i = 0 ] && + printf "$device_alias" || + printf ', %s' "$device_alias" + + i=$((i + 1)) + fi + done <<-EOT + $(bluetoothctl devices Paired | cut -d ' ' -f 2) + EOT + + printf "\n" +else + echo '' +fi