diff options
author | Saumit Dinesan <79687674+justsaumit@users.noreply.github.com> | 2022-02-26 11:34:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-26 11:34:04 +0530 |
commit | 584dd7d7c6ac75f70ceaeec969ff7f6ba7c4457d (patch) | |
tree | 825ee7a069545f994f4a7b853181f863237dd86c | |
parent | 1f9cf510bd39f4fd5feb99e5b98f00880de4552e (diff) |
Update bts
-rw-r--r-- | scripts/bts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/bts b/scripts/bts index 29b9200..0929f73 100644 --- a/scripts/bts +++ b/scripts/bts @@ -3,14 +3,17 @@ 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 - notify-send "Bluetooth Device is connected";; - "inactive" | "failed") + bluetoothctl connect A1:B3:EC:B1:53:60 && sleep 5 && + pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) + [ "$pmstat" = ("a2dp_sink" || "handsfree_head_unit") ] && notify-send "Bluetooth Device is connected"|| notify-send "Unable to connect! Check whether the bluetooth device is switched on.";; + + "inactive" | "failed") export SUDO_ASKPASS=/home/saumit/.scripts/dpass sudo -A systemctl start bluetooth - #st -e sudo systemctl start bluetooth + #st -e sudo systemctl start bluetooth && notify-send "Bluetooth daemon is running" bluetoothctl power on - bluetoothctl connect A1:B3:EC:B1:53:60 - notify-send "Bluetooth Device is connected";; + bluetoothctl connect A1:B3:EC:B1:53:60 && + pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) + [ "$pmstat" = "a2dp_sink" ] && notify-send "Bluetooth Device is connected" || notify-send "Unable to connect! Check whether the bluetooth device is switched on.";; esac |