From 30734e201058f09e54de857e715d9afb6d095f37 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Sat, 5 Mar 2022 08:24:38 +0100 Subject: [PATCH] Reduced hanging possibilities due to `bluetoothctl` in Polybar bluetooth script, making it check if kernel module is loaded and a BT card is plugged --- polybar/.config/polybar/scripts/bluetooth.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/polybar/.config/polybar/scripts/bluetooth.sh b/polybar/.config/polybar/scripts/bluetooth.sh index 5c90b6e..45ef0ca 100755 --- a/polybar/.config/polybar/scripts/bluetooth.sh +++ b/polybar/.config/polybar/scripts/bluetooth.sh @@ -1,6 +1,17 @@ #!/bin/sh # Usage: ./bluetooth.sh [--toggle] +set -e + +# If the folder doesn't exist (kernel module not loaded) or it's empty, exit +if [ ! -d /sys/class/bluetooth ]; then + exit 1 +elif [ -z "$(ls -A /sys/class/bluetooth)" ]; then + exit 1 +else + : +fi + case $1 in "") bt_color=""