diff --git a/wireless.sh b/wireless.sh index 7ed378e..6204701 100755 --- a/wireless.sh +++ b/wireless.sh @@ -1,42 +1,45 @@ #!/usr/bin/env bash # # Yigid BALABAN, +# wireless.sh # +# description +# toggle wifi and bluetooth on or off quickly control() { - local device="$1" - local subcommand="$2" + local device="$1" + local subcommand="$2" - case "$subcommand" in - off) - rfkill block "$device" && + case "$subcommand" in + off) + rfkill block "$device" && + case $device in + bluetooth) bluetoothctl power off ;; + wifi) nmcli radio wifi off ;; + esac + ;; + on) - case $device in - bluetooth) bluetoothctl power off ;; - wifi) nmcli radio wifi off ;; - esac - ;; - on) - - rfkill unblock "$device" && sleep 1 && - - case $device in - bluetooth) bluetoothctl power on ;; - wifi) nmcli radio wifi on ;; - esac - ;; - *) - # shellcheck disable=SC2154 - echo "$command: subcommand '$subcommand' is not a valid argument." >&2 - return 1 - esac + rfkill unblock "$device" && sleep 1 && + case $device in + bluetooth) bluetoothctl power on ;; + wifi) nmcli radio wifi on ;; + esac + ;; + *) + # shellcheck disable=SC2154 + echo "$command: subcommand '$subcommand' is not a valid argument." >&2 + return 1 + ;; + esac } if [[ $# -ne 2 ]]; then - echo "Usage: $0 " >&2 - echo "Valid devices: bluetooth, wifi" >&2 - echo "Valid subcommands: on, off" >&2 - exit 1 + echo "Usage: $0 " >&2 + echo "Valid devices: bluetooth, wifi" >&2 + echo "Valid subcommands: on, off" >&2 + exit 1 fi -control "$1" "$2" +control "$1" "$2" & +disown