dotfiles/.local/bin/wifi-toggle

27 lines
432 B
Text
Raw Normal View History

2026-08-03 14:30:55 +02:00
#!/bin/sh
# Toggle the WiFi on or off
set -eu
_notify() {
command -v notify-send >/dev/null 2>&1 || return 0
notify-send 'WiFi' "$1"
}
case "$(nmcli -t radio wifi)" in
enabled)
nmcli radio wifi off
_notify 'Radio turned off'
;;
disabled)
nmcli radio wifi on
_notify 'Radio turned on'
;;
*)
_notify 'No radio available'
exit 1
;;
esac