wifi connectivity script
This commit is contained in:
parent
102ee41c0d
commit
c000ee9ef7
78
wifi
Executable file
78
wifi
Executable file
@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
# TODO: rid ourselves of plaintext configs which can have sensitive network keys
|
||||
|
||||
cfg_loc="$HOME/.config/wifi-configs/"
|
||||
iface="wlp1s0"
|
||||
|
||||
debug_kill='on'
|
||||
__write_config() {
|
||||
printf "network={
|
||||
ssid=\"$2\"
|
||||
psk=\"$3\"
|
||||
}\n" # > "$cfg_loc/$1"
|
||||
}
|
||||
|
||||
__kill_old() {
|
||||
if [ ! -z "$debug_kill" ]
|
||||
then
|
||||
kill `pgrep wpa`
|
||||
dhclient -r
|
||||
else
|
||||
echo 'Not killing anything'
|
||||
fi
|
||||
}
|
||||
|
||||
_reconnect_config() {
|
||||
__kill_old
|
||||
if [ ! -z "$debug_kill" ]
|
||||
then
|
||||
__kill_old
|
||||
else
|
||||
echo 'No restart'
|
||||
fi
|
||||
}
|
||||
|
||||
remove_old_config() {
|
||||
name="`echo '' | dmenu -i -p 'Name of config to remove(This will disconnect you)'`"
|
||||
rm -f "$cfg_loc/$name"
|
||||
__kill_old
|
||||
}
|
||||
|
||||
create_new_config() {
|
||||
name="`echo '' | dmenu -i -p 'Name of new config'`"
|
||||
type="`printf "WPA2 Personal\nWPA2 Enterprise" | dmenu -i -p 'Connection Type'`"
|
||||
|
||||
case $type in
|
||||
*Personal)
|
||||
ssid="`echo '' | dmenu -p 'SSID'`"
|
||||
psk="`echo '' | dmenu -p 'Passkey'`"
|
||||
__write_config "$HOME/.config//$name" "$ssid" "$psk"
|
||||
con="`printf "Yes\nNo" | dmenu -i -p 'Connect with new config?'`"
|
||||
if [ "$con" = "Yes" ]
|
||||
then
|
||||
_reconnect_config $con
|
||||
fi
|
||||
;;
|
||||
*Enterprise)
|
||||
echo 'Not yet implemented' | dmenu -p 'SSID'
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
reconnect_old_config() {
|
||||
name="`ls $cfg_loc | dmenu -i -p 'Choose config to connect with'`"
|
||||
if [ -f $name ]
|
||||
then
|
||||
rm -f "$cfg_loc/$name"
|
||||
__kill_old
|
||||
fi
|
||||
}
|
||||
|
||||
option=`printf "Remove\nReconnect\nNew\n" | dmenu -i`
|
||||
case $option in
|
||||
New) create_new_config;;
|
||||
Remove) remove_old_config;;
|
||||
Reconnect) reconnect_old_config;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user