wifi update

This commit is contained in:
Adrian Amaglio 2022-03-11 13:43:21 +01:00
parent 4735d58b77
commit 35f8cdfba0
2 changed files with 35 additions and 10 deletions

View File

@ -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

View File

@ -2,6 +2,32 @@
# choose a wifi signal in range and try to connect to it # choose a wifi signal in range and try to connect to it
verb=0 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" title="Wifi Selector"
id="" id=""
@ -13,10 +39,18 @@ notify () {
fi 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 if ( nmcli radio wifi | grep disabled > /dev/null ) ; then
notify "Turning on" notify "Turning on"
nmcli radio wifi on nmcli radio wifi on
sleep 1 sleep 2
fi fi
notify "Scanning networks in range..." notify "Scanning networks in range..."