31 lines
422 B
Bash
31 lines
422 B
Bash
|
#!/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
|