45 lines
874 B
Bash
Executable File
45 lines
874 B
Bash
Executable File
#!/bin/sh
|
|
|
|
[ "$(pgrep -c NetworkManager)" -eq 1 ] &&
|
|
printf "NetworkManager is already running!\n" &&
|
|
exit
|
|
|
|
case $1 in
|
|
"c"*)
|
|
wpa_supplicant -iwlp3s0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B
|
|
dhcpcd wlp3s0
|
|
# make tor and nohup shut up in a posix-compliant way
|
|
nohup tor >/dev/null 2>&1
|
|
;;
|
|
"d"*)
|
|
killall -15 wpa_supplicant dhcpcd tor
|
|
;;
|
|
"r"*)
|
|
sh "$0" d
|
|
sh "$0" c
|
|
;;
|
|
"t"*)
|
|
[ "$(pgrep -c wpa_supplicant)" -eq 1 ] && sh "$0" d && exit
|
|
sh "$0" c
|
|
;;
|
|
"l"*)
|
|
iw dev wlp3s0 scan | \
|
|
grep 'SSID\|signal' | \
|
|
grep -v 'SSID List' | \
|
|
awk -F': ' '{print $2}' | \
|
|
sed 'N;s/\n/ /' | \
|
|
grep -v '\x00'
|
|
;;
|
|
*)
|
|
echo "
|
|
simple wrapper for connecting to a network
|
|
${0} toggle to toggle wifi connection
|
|
${0} restart to restart wifi
|
|
${0} disconnect to disconnect
|
|
${0} connect to connect to network
|
|
${0} list to list networks
|
|
"
|
|
;;
|
|
esac
|
|
exit 0
|