From d71e6f7e1cb441b994839511641aa33e455d824c Mon Sep 17 00:00:00 2001 From: Saumit Dinesan <79687674+Saumit-D@users.noreply.github.com> Date: Tue, 25 Jan 2022 23:04:43 +0530 Subject: Update bts using grep and cut for first time... I believe the code can get much much smaller --- scripts/bts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/bts b/scripts/bts index 2900ef9..0acdefd 100644 --- a/scripts/bts +++ b/scripts/bts @@ -1,4 +1,10 @@ -bluetoothctl power on -bluetoothctl connect A1:B3:EC:B1:53:60 -bluetoothctl connect A1:B3:EC:B1:53:60 - +status=$(systemctl status bluetooth | grep active | cut -d " " -f 7) +case $status in + "active") + bluetoothctl power on + bluetoothctl connect A1:B3:EC:B1:53:60 ;; + "inactive") + sudo systemctl start bluetooth + bluetoothctl power on + bluetoothctl connect A1:B3:EC:B1:53:60;; +esac -- cgit v1.2.3