1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Must be run as root
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
on() {
rfkill unblock bluetooth
case "$SXMO_OS" in
alpine|postmarketos)
rc-service bluetooth start
rc-update add bluetooth
;;
arch|archarm|nixos)
systemctl start bluetooth
systemctl enable bluetooth
;;
esac
}
off() {
case "$SXMO_OS" in
alpine|postmarketos)
rc-service bluetooth stop
rc-update del bluetooth
;;
arch|archarm|nixos)
systemctl stop bluetooth
systemctl disable bluetooth
;;
esac
rfkill block bluetooth
}
case "$1" in
on)
on
;;
off)
off
;;
*) #toggle
if rfkill list bluetooth | grep -q "yes"; then
on
else
off
fi
esac
|