blob: a57aecde7eb0e350bd7af0f8708399962a5be964 (
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
50
51
52
53
54
55
56
57
58
59
|
#!/bin/bash
set -e
[ -n "$DEBUG" ] && set -x
export UNSAFE=1
# notifysend() {
# [ -z "$notifyicon" ] && notifyicon=bluetooth
# local msg=$1
# shift 1
# echo "$msg"
# notification_id=$(notify-send "bluetooth" "$msg" -i "$(iconez -sn "$notifyicon")" --print-id "$@")
# }
if [ -n "$BTON" ]; then
bluetoothctl power on
exit $?
fi
if [ -n "$BTOFF" ]; then
bluetoothctl power off
exit $?
fi
if [ -n "$BTCONNECT" ]; then
if [ -n "$REEXEC" ]; then
addr=$1
if bluetoothctl devices Connected | grep -q "$addr"; then
bluetoothctl disconnect "$addr"
else
bluetoothctl connect "$addr"
sleep 2
# hack to make wireplumber detect bt audio device
pkill -USR2 wireplumber
fi
exit $?
fi
bluetoothctl power on
bluetoothctl devices |
while read -r btdev; do
name=$(cut -d' ' -f3 <<<"$btdev")
addr=$(cut -d' ' -f2 <<<"$btdev")
jq -cnr \
--arg label "$name $addr" \
--arg addr "$addr" \
'{l:$label,x:(["env BTCONNECT=1 REEXEC=1 bluemenu", $addr]|join(" "))}'
done |
jq -cs '{p:"bluemenu", o:.}' |
mkmenu
exit $?
fi
jq -cn '{p:"bluetooth",o:[{l:"connect...",x:"env BTCONNECT=1 bluemenu"},{l:"power on",x:"env BTON=1 bluemenu"},{l:"power off",x:"env BTOFF=1 bluemenu"}]}' |
mkmenu
|