make func call async
This commit is contained in:
parent
15bda21067
commit
a2724ef837
61
wireless.sh
61
wireless.sh
@ -1,42 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Yigid BALABAN, <fyb@fybx.dev>
|
||||
# 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 <device> <subcommand>" >&2
|
||||
echo "Valid devices: bluetooth, wifi" >&2
|
||||
echo "Valid subcommands: on, off" >&2
|
||||
exit 1
|
||||
echo "Usage: $0 <device> <subcommand>" >&2
|
||||
echo "Valid devices: bluetooth, wifi" >&2
|
||||
echo "Valid subcommands: on, off" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
control "$1" "$2"
|
||||
control "$1" "$2" &
|
||||
disown
|
||||
|
Loading…
x
Reference in New Issue
Block a user