Rewritten polybar's bluetooth script

master
Meliurwen 3 years ago
parent 6c7b3f00ad
commit f565fb5ed5
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 4
      polybar/.config/polybar/config
  2. 34
      polybar/.config/polybar/scripts/bluetooth.sh
  3. 7
      polybar/.config/polybar/scripts/toggle_bluetooth.sh

@ -271,7 +271,7 @@ click-left = printf "%s\n" "cycle pause" | socat - ~/.cache/mpvsocket
type = custom/script type = custom/script
exec = ~/.config/polybar/scripts/bluetooth.sh exec = ~/.config/polybar/scripts/bluetooth.sh
interval = 5 interval = 5
click-left = exec blueberry & click-left = blueman-manager &
click-right = exec ~/.config/polybar/scripts/toggle_bluetooth.sh & click-right = ~/.config/polybar/scripts/bluetooth.sh --toggle &
format-background = #000000 format-background = #000000
format-foreground = #ffffff format-foreground = #ffffff

@ -1,12 +1,26 @@
#!/bin/sh #!/bin/sh
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] # Usage: ./bluetooth.sh [--toggle]
then
echo "%{F#66ffffff}"
else
if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]
then
echo ""
fi
echo "%{F#2193ff}"
fi
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

@ -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
Loading…
Cancel
Save