blob: 708f51e96222dfa977f9ee3e83f4b63c9e3affba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env bash
declare -a states
ARG=${1:-$BLOCK_BUTTON}
# Get state and exit if its soft/hard blocked
for A in $(rfkill -o TYPE,SOFT,HARD | awk '/bluetooth/{print $2 "\n" $3}'); do
[ $A == "blocked" ] && exit 0
done
DAEMONSTATUS="$(systemctl is-active bluetooth.service)"
if [ "$DAEMONSTATUS" == "inactive" ]; then
echo -en '\x0c\uf5b1\x0b'
case $ARG in
1) systemctl start bluetooth.service;;
esac
else
CONNECTED="$(bluetoothctl info | awk '/Name/{$1=""; print $0}')"
if [ -z "${CONNECTED}" ]; then
# Not connected
echo -ne '\x0f\uf5b0\x0b'
case $ARG in
1) notify-send 'Bluetooth status' "Disconnected\n$(bluetoothctl paired-devices)"
esac
else
echo -ne '\x0d\uf5ae\x0b'
case $ARG in
1) notify-send 'Bluetooth status' "Connected to ${CONNECTED}";;
3) bluetoothctl disconnect
esac
fi
fi
|