mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-25 20:58:37 -06:00
chg: Tidy up bluetooth-toggle
This commit is contained in:
parent
915bb4fce6
commit
9301a586df
1 changed files with 10 additions and 8 deletions
|
@ -4,19 +4,21 @@
|
|||
# I use it with a shortcut.
|
||||
#
|
||||
|
||||
BLUETOOTH_DEVICE=$(bluetoothctl list | grep dongle | awk '{print $2}')
|
||||
if [ -z $BLUETOOTH_DEVICE ]; then
|
||||
BLUETOOTH_DEVICE=$(bluetoothctl list | head -1 | awk '{print $2}')
|
||||
DONGLE_MAC=$(bluetoothctl list | grep dongle | awk '{print $2}')
|
||||
INTERNAL_MAC=$(bluetoothctl list | grep internal | awk '{print $2}')
|
||||
|
||||
if [ -z $DONGLE_MAC ]; then
|
||||
DEVICE_MAC=$INTERNAL_MAC
|
||||
else
|
||||
BLUETOOTH_DEVICE_OTHER=$(bluetoothctl list | grep internal | awk '{print $2}')
|
||||
echo -e "select $BLUETOOTH_DEVICE_OTHER\npower off" | bluetoothctl
|
||||
DEVICE_MAC=$DONGLE_MAC
|
||||
echo -e "select $INTERNAL_MAC\npower off" | bluetoothctl
|
||||
fi
|
||||
|
||||
if [ $(bluetoothctl show $BLUETOOTH_DEVICE | grep Powered | grep -c yes) == 1 ]; then
|
||||
echo -e "select $BLUETOOTH_DEVICE\npower off" | bluetoothctl
|
||||
if [ $(bluetoothctl show $DEVICE_MAC | grep Powered | grep -c yes) == 1 ]; then
|
||||
echo -e "select $DEVICE_MAC\npower off" | bluetoothctl
|
||||
else
|
||||
if [ $(rfkill --output-all | grep bluetooth | grep -c blocked) != 0 ]; then
|
||||
rfkill unblock bluetooth
|
||||
fi
|
||||
echo -e "select $BLUETOOTH_DEVICE\npower on" | bluetoothctl
|
||||
echo -e "select $DEVICE_MAC\npower on" | bluetoothctl
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue