make func call async

This commit is contained in:
yigid balaban 2024-09-09 00:22:41 +03:00
parent 15bda21067
commit a2724ef837
Signed by: fyb
GPG Key ID: E21FEB2C244CB7EB

View File

@ -1,7 +1,10 @@
#!/usr/bin/env bash
#
# Yigid BALABAN, <fyb@fybx.dev>
# wireless.sh
#
# description
# toggle wifi and bluetooth on or off quickly
control() {
local device="$1"
@ -10,7 +13,6 @@ control() {
case "$subcommand" in
off)
rfkill block "$device" &&
case $device in
bluetooth) bluetoothctl power off ;;
wifi) nmcli radio wifi off ;;
@ -19,7 +21,6 @@ control() {
on)
rfkill unblock "$device" && sleep 1 &&
case $device in
bluetooth) bluetoothctl power on ;;
wifi) nmcli radio wifi on ;;
@ -29,6 +30,7 @@ control() {
# shellcheck disable=SC2154
echo "$command: subcommand '$subcommand' is not a valid argument." >&2
return 1
;;
esac
}
@ -39,4 +41,5 @@ if [[ $# -ne 2 ]]; then
exit 1
fi
control "$1" "$2"
control "$1" "$2" &
disown