blob: 7f276df4b96e680f5cccfd168a03e777c94f0e04 (
plain) (
blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/bin/bash
turn_on() {
rfkill unblock bluetooth
bluetoothctl power on
notify "on"
}
turn_off() {
rfkill unblock bluetooth
bluetoothctl power off
notify "off"
}
toggle() {
if bluetoothctl <<< show | grep -q "Powered: yes"; then
turn_off
else
turn_on
fi
}
notify() {
local class="$1"
notify-send -e \
-h string:x-canonical-private-synchronous:bluetooth \
-u low \
"Bluetooth" \
" ${class}"
}
case "$1" in
"--on")
turn_on
;;
"--off")
turn_off
;;
"--toggle")
toggle
;;
*)
echo -e "Usage:"
echo -e " --on to turn bluetooth on"
echo -e " --off to turn bluetooth off"
echo -e " --toggle to toggle bluetooth state"
exit 0
;;
esac
|