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