dotfiles/.config/eww/scripts/get-bluetooth.sh

31 lines
422 B
Bash
Raw Normal View History

2024-11-19 09:37:19 +01:00
#!/bin/bash
interval=2
function get {
unset icon state device
if bluetoothctl show | grep -q 'Powered: no'; then
icon="󰂲"
state="disabled"
device="Disabled"
else
icon="󰂯"
state="powered"
device="Not connected"
fi
cat << EOF
{"icon": "$icon", "state": "$state", "device": "$device"}
EOF
}
if [[ "$1" == "once" ]]; then
get
else
while :; do
get
sleep $interval
done
fi