blob: 13fe8cc9f19d47bf78e84640893ae989deb6d6a9 (
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
34
35
|
#!/bin/sh
# initial configuration
# sudo pacman --noconfirm -S bluez-utils pulseaudio-bluetooth pulseaudio-alsa blueman
# sudo ln -vsf ${PWD}/etc/bluetooth/main.conf /etc/bluetooth/main.conf
# Requires:
# blueman
# bluez-utils
# networkmanager_dmenu (https://github.com/firecat53/networkmanager-dmenu)
# btmenu (https://github.com/cdown/btmenu)
grep -q 'down' /sys/class/net/w*/operstate && wifiicon="❌"
[ -z "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "🛜", int($3 * 100 / 70) "%" }')
wifi=$(printf "%s %s" "${wifiicon}" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate)")
if [ -n "${wifi}" ]; then
choice=$(printf 'bluetooth\nnetwork\nwifi' | dmenu -i -p "${wifi}")
else
choice=$(printf 'bluetooth\nnetwork\nwifi' | dmenu -i -p 'Connect:')
fi
case "${choice}" in
bluetooth)
[ -z "$(pgrep blueman)" ] && blueman-applet &
case "$(printf 'connect\ndisable\nmanage\nnew' | dmenu -i -p 'bluetooth:')" in
connect) btmenu ;;
disable) sudo rkill block bluetooth ;;
manage | new) $TERMINAL bluetoothctl ;;
esac
;;
network) networkmanager_dmenu ;;
wifi) nmcli -c no d wifi list | tail -n +2 | sed 's/ \+/ /;s/Infra [0-9]*/ /g;s/WPA. .*$//;s/Mbit\/s[[:space:]]*[0-9]*/Mbit\/s/g;s/Ad-Hoc [0-9]*//g' | dmenu -i -l 20 -p Networks ;;
esac
|