diff options
author | ubuntuperonista <30541016+ubuntuperonista@users.noreply.github.com> | 2023-01-28 22:21:20 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 22:21:20 -0300 |
commit | dfe43a632380841e75e1bcdfc1a90ff45a10d6d4 (patch) | |
tree | eb08cbfcbba6d01567bc75d293e073d2f22a637f | |
parent | ebc8ddb8a7525d845569df7fa738bc992557a950 (diff) | |
download | wifi_toggle-dfe43a632380841e75e1bcdfc1a90ff45a10d6d4.tar.gz |
Create wifi_toggle.sh
-rw-r--r-- | wifi_toggle.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/wifi_toggle.sh b/wifi_toggle.sh new file mode 100644 index 0000000..9b41e6a --- /dev/null +++ b/wifi_toggle.sh @@ -0,0 +1,44 @@ +#!/bin/sh +## This script toggles the Wifi adapter(s). +## Works on Ubuntu 16.04lts and up. +STATEFILE="/tmp/wifitoggle.state" + +if [ $# -eq 1 ]; then + case $1 in + "up"|"on") + STATE=off + ;; + "down"|"off") + STATE=on + ;; + esac +else + if [ ! -e ${STATEFILE} ]; then + STATE=on + else + . ${STATEFILE} + fi +fi +if [ -z ${STATE} ]; then + STATE=on +fi + +if [ ${STATE} = "on" ]; then + nmcli radio wifi off + STATE=off + echo 'Wifi off' + notify-send 'Wifi off' + ## uncomment for optional sound cue + #play -q ~/PĂșublic/wifioff.ogg -t alsa & # +# disown # +else + nmcli radio wifi on + STATE=on + echo 'Wifi on' + notify-send 'Wifi on' + ##Uncomment for optional sound cue + #play -q ~/Public/wifion.ogg -t alsa & # + # disown # +fi + +echo "STATE=${STATE}" > ${STATEFILE} |