diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2022-03-12 19:54:51 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2022-03-12 19:54:51 +0530 |
commit | 54b772cae06eb25adf33297e35234f33ded81a7b (patch) | |
tree | f287ee48faa8013e4a8f0ee764a6d3cd850bb24d /.scripts/bts | |
parent | 7197e45d94dbcf4877d585fff8e634896876ae83 (diff) |
neovim addition
Diffstat (limited to '.scripts/bts')
-rwxr-xr-x | .scripts/bts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.scripts/bts b/.scripts/bts new file mode 100755 index 0000000..7b85aac --- /dev/null +++ b/.scripts/bts @@ -0,0 +1,37 @@ +#!/bin/bash +option=$(echo -e "Connect\nDisconnect\nChange profile"| dmenu -p "Do you wish to connect/disconnect or change soundprofile of your bluetooth device:") +MAC=$(echo "A1:B3:EC:B1:53:60") +case $option in + "Connect") + status=$(systemctl status bluetooth | grep Active | cut -d " " -f 7) + case $status in + "active") + bluetoothctl power on + bluetoothctl connect $MAC && sleep 2 && [ $(bluetoothctl info $MAC|grep "Connected"|awk -F'[:][ ]' '/^[^#]/{print $2}') == "yes" ] && notify-send "Connected" "Bluetooth Device is connected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on.";; + + "inactive" | "failed") + sudo -A systemctl start bluetooth + #st -e sudo systemctl start bluetooth && + notify-send "Bluetooth daemon is running" + bluetoothctl power on + bluetoothctl connect $MAC && sleep 1 && [ $(bluetoothctl info $MAC|grep "Connected"|awk -F'[:][ ]' '/^[^#]/{print $2}') == "yes" ] && notify-send "Connected" "Bluetooth Device is disconnected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on."; + esac;; + + "Disconnect") + bluetoothctl power off && sudo -A systemctl stop bluetooth + notify-send "Disconnected" "Bluetooth Device is connected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on.";; + + "Change profile") + past_profile=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) + profile=$(echo -e "a2dp_sink(pure audio output)\nhandsfree_head_unit(inferior audio output + mic enable)" | dmenu -p "Choose the profile for your sound card") + cardindex=$(pacmd list-cards | grep 'index' | awk 'NR==2' | cut -d ' ' -f6) + + case $profile in + "a2dp_sink(pure audio output)") + pactl set-card-profile $cardindex a2dp_sink && + dunstify "Switched card profile from $past_profile to $profile" -i audio-headphones;; + "handsfree_head_unit(inferior audio output + mic enable)") + pactl set-card-profile $cardindex handsfree_head_unit + notify-send "Switched card profile from $past_profile to $profile" -i audio-headset;; + esac +esac |