Last active
October 20, 2018 04:03
-
-
Save ikr7/a7c3d74294851ba869413932795c3d8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IFNAME="wlp36s0" | |
if [ "$1" = "off" ]; then | |
nmcli device disconnect $IFNAME | |
exit 0 | |
fi | |
if [ "$1" = "on" ]; then | |
nmcli device connect $IFNAME | |
exit 0 | |
fi | |
if [ "$1" = "select" ]; then | |
SSID=$(nmcli device wifi list ifname $IFNAME | tail -n +2 | peco --prompt "Select SSID to connect" | cut -f 9 -d " ") | |
if [ "$SSID" = "" ]; then | |
echo "No SSID selected." | |
exit 1 | |
fi | |
read -p "Enter password for $SSID : " -s PASS | |
echo "" | |
echo "Connecting..." | |
nmcli device wifi connect $SSID ifname $IFNAME password $PASS | |
exit 0 | |
fi | |
echo "Invalid command '$1'" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment