2022-01-26 20:40:22 +00:00
#!/bin/sh
# _____ ___ ___
# / /::\ / /\ /__/|
# / /:/\:\ / /::\ | |:| ***This script was made by Clay Gomera (Drake)***
# / /:/ \:\ / /:/\:\ | |:| - Description: A simple wifi-menu dmenu script
# /__/:/ \__\:| / /:/~/:/ __| |:| - Dependencies: dmenu, notify-send, NetworkManager, ping
# \ \:\ / /:/ /__/:/ /:/___ /__/\_|:|____
# \ \:\ /:/ \ \:\/:::::/ \ \:\/:::::/
# \ \:\/:/ \ \::/~~~~ \ \::/~~~~
# \ \::/ \ \:\ \ \:\
# \__\/ \ \:\ \ \:\
# \__\/ \__\/
# Dmenu variables
DMENU1 = "dmenu -l 10 -b -i -p"
DMENU2 = "dmenu -b -i -p"
# Scanning Networks and notification
notify-send "Scanning Networks"
nmcli -t d wifi rescan
scan = $( nmcli --fields SSID,SECURITY,BARS device wifi list | sed '/^--/d' | sed 1d | sed -E "s/WPA*.?\S/~~/g" | sed "s/~~ ~~/~~/g;s/802\.1X//g;s/--/~~/g;s/ *~/~/g;s/~ */~/g;s/_/ /g" | column -t -s '~' )
# Selecting Network
selectnet( ) {
bssid = $( echo " $scan " | uniq -u | $DMENU1 "Select Wifi :" | cut -d' ' -f1)
if [ " $bssid " ] ; then
query = $bssid
else
exit 0
fi
}
# Typing password
selectpass( ) {
pass = $( $DMENU2 "Enter Password :" )
if [ " $pass " ] ; then
passqry = $pass
else
exit 0
fi
}
2022-02-28 03:08:25 +00:00
selectnet
2022-01-26 20:40:22 +00:00
selectpass
# Main connection command
2022-02-28 03:08:25 +00:00
nmcli dev wifi connect " $query " password "" $passqry ""
2022-01-26 20:40:22 +00:00
# Check notification
notify-send "Checking if the connection was successful"
# Check process
sleep 10
if ping -q -c 2 -W 2 google.com >/dev/null; then
notify-send "Your internet is working :)"
else
notify-send "Your internet is not working :("
fi