wifi_conn (678B)
1 #!/bin/sh 2 3 # chose a network 4 network=`nmcli -f SSID dev wifi list | tail -n +2 | sort -u | grep -v '\-\-' | sed 's/ *$//' | rofi -dmenu` 5 pass=`rofi -password -p 'Password' -dmenu -show window` 6 7 # connect to network 8 msg=`nmcli device wifi connect $network password $pass 2>&1` 9 10 # interpret the results 11 case "$msg" in 12 *failed*) 13 notify-send -u critical "WiFi" "Failed to connect to $network" 14 ;; 15 *No\ network\ with\ SSID*) 16 notify-send -u critical "WiFi" "Could not find network with SSID '$network'" 17 ;; 18 *missing*) 19 notify-send -u critical "WiFi" "Password not provided" 20 ;; 21 *) 22 notify-send "wifi" "Successfully connected to '$network'" 23 ;; 24 esac