diff options
author | ubuntuperonista <30541016+ubuntuperonista@users.noreply.github.com> | 2023-01-28 22:16:20 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 22:16:20 -0300 |
commit | 224426ee8bb9ce886287a54506abed98f6c452b4 (patch) | |
tree | f8f7ad9c132398090a875c7dbf6c24e274903262 | |
parent | 16947caa854ea233a408932bfc41cbe7c4765d58 (diff) | |
download | wifi_toggle-224426ee8bb9ce886287a54506abed98f6c452b4.tar.gz |
Create wifi_toggle
-rw-r--r-- | wifi_toggle | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/wifi_toggle b/wifi_toggle new file mode 100644 index 0000000..3d54e8c --- /dev/null +++ b/wifi_toggle @@ -0,0 +1,42 @@ +#!/bin/sh +## This scrips toggle the wifi adator. +## Works on Ubuntu 16.04lts and up. +STATEFILE="/tmp/wifionoff.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 apagado' + play -q ~/Público/wifioff.ogg -t alsa & # +# disown # +else + nmcli radio wifi on + STATE=on + echo 'Wifi on' + notify-send 'Wifi encendido' + play -q ~/Público/wifion.ogg -t alsa & # +# disown # +fi + +echo "STATE=${STATE}" > ${STATEFILE} |