diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 5fec84f..a35f481 100644 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -271,7 +271,7 @@ click-left = printf "%s\n" "cycle pause" | socat - ~/.cache/mpvsocket type = custom/script exec = ~/.config/polybar/scripts/bluetooth.sh interval = 5 -click-left = exec blueberry & -click-right = exec ~/.config/polybar/scripts/toggle_bluetooth.sh & +click-left = blueman-manager & +click-right = ~/.config/polybar/scripts/bluetooth.sh --toggle & format-background = #000000 format-foreground = #ffffff diff --git a/polybar/.config/polybar/scripts/bluetooth.sh b/polybar/.config/polybar/scripts/bluetooth.sh index fea6d95..58d63e3 100755 --- a/polybar/.config/polybar/scripts/bluetooth.sh +++ b/polybar/.config/polybar/scripts/bluetooth.sh @@ -1,12 +1,26 @@ #!/bin/sh -if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] -then - echo "%{F#66ffffff}" -else - if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ] - then - echo "" - fi - echo "%{F#2193ff}" -fi +# Usage: ./bluetooth.sh [--toggle] +case $1 in + "") + if [ "$(bluetoothctl show | grep "Powered: yes" | wc -c)" -eq 0 ]; then + printf "%s\n" "%{F#66ffffff}" + elif [ "$(printf "%s\n" info | bluetoothctl | grep 'Device' | wc -c)" -eq 0 ]; then + printf "%s\n" "" + printf "%s\n" "%{F#2193ff}" + else + printf "%s\n" "%{F#2193ff}" + fi + ;; + "--toggle") + if [ "$(bluetoothctl show | grep "Powered: yes" | wc -c)" -eq 0 ]; then + bluetoothctl power on + else + bluetoothctl power off + fi + ;; + *) + printf "Parameter not supported. Aborting...\n" + exit 1 + ;; +esac diff --git a/polybar/.config/polybar/scripts/toggle_bluetooth.sh b/polybar/.config/polybar/scripts/toggle_bluetooth.sh deleted file mode 100755 index dffb663..0000000 --- a/polybar/.config/polybar/scripts/toggle_bluetooth.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] -then - bluetoothctl power on -else - bluetoothctl power off -fi