diff --git a/switch-wifi b/switch-wifi deleted file mode 100755 index a20a6bf..0000000 --- a/switch-wifi +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -if [[ "$(nmcli radio wifi)" = "enabled" ]] ; then - nmcli radio wifi off - notify-send "Wifi is now" off -else - nmcli radio wifi on - notify-send "Wifi is now" on - wifi_chooser -fi diff --git a/wifi_chooser b/wifi_chooser index 5de0224..3e13a66 100755 --- a/wifi_chooser +++ b/wifi_chooser @@ -2,6 +2,32 @@ # choose a wifi signal in range and try to connect to it verb=0 +action=start + +while true ; do + case "$1" in + "-v") + verb=1 + ;; + "stop") + action=stop + ;; + "start") ;; + "") break ;; + *) + echo "Invalid parameter '$1'" + break;; + esac + shift +done +# Remaining args are garbage +if [ "$#" -ne 0 ] ; then + echo "Usage: $0 [-v] [start|stop]" + echo "-v verbose output" + echo "start or stop the wifi" + exit -1 +fi + title="Wifi Selector" id="" @@ -13,10 +39,18 @@ notify () { fi } +# Stop the wifi if asked +if [ "$action" == "stop" ] ; then + nmcli radio wifi off + notify "Wifi stopped" + exit "$?" +fi + +# Else, start it if needed if ( nmcli radio wifi | grep disabled > /dev/null ) ; then notify "Turning on" nmcli radio wifi on - sleep 1 + sleep 2 fi notify "Scanning networks in range..."