30 lines
828 B
Bash
30 lines
828 B
Bash
|
#!/bin/sh
|
||
|
|
||
|
bssid="$(nmcli --colors=no -f BSSID,IN-USE,SSID,BARS device wifi list\
|
||
|
| tail -n+2\
|
||
|
| fuzzel -d -p "connect > "\
|
||
|
| cut -d" " -f1)"
|
||
|
|
||
|
[ -z "$bssid" ] && return
|
||
|
|
||
|
ssid="$(nmcli -g SSID device wifi list bssid "$bssid" --rescan no)"
|
||
|
|
||
|
if nmcli -t connection show "$ssid" >/dev/null 2>&1; then
|
||
|
if nmcli device wifi connect "$bssid" 2>&1; then
|
||
|
exec notify-send "Connected to $ssid."
|
||
|
else
|
||
|
exec notify-send "Could not connect to $ssid."
|
||
|
fi
|
||
|
else
|
||
|
security="$(nmcli -g SECURITY device wifi list bssid "$bssid" --rescan no)"
|
||
|
if [ "$security" = "WPA2" ] || [ "$security" = "WEP" ]; then
|
||
|
password="$(fuzzel -d --password -p "password > ")"
|
||
|
fi
|
||
|
|
||
|
if nmcli device wifi connect "$bssid" password "$password" 2>&1; then
|
||
|
exec notify-send "Connected to $ssid."
|
||
|
else
|
||
|
exec notify-send "Could not connect to $ssid."
|
||
|
fi
|
||
|
fi
|