diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bts | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/scripts/bts b/scripts/bts index 3e91f35..d082132 100644 --- a/scripts/bts +++ b/scripts/bts @@ -1,19 +1,41 @@ #!/bin/bash -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 && sleep 5 && - pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) - [ -n "$pmstat" ] && notify-send "Bluetooth Device is connected"|| notify-send "Unable to connect! Check whether the bluetooth device is switched on.";; +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.";; + #pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) && + #[ -n "$pmstat" ] && notify-send "Connected" "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 && - notify-send "Bluetooth daemon is running" - bluetoothctl power on - bluetoothctl connect A1:B3:EC:B1:53:60 && - pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) - [ -n "$pmstat" ] && 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 && + 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 connected" || notify-send "Unable to connect!" "Check whether the bluetooth device is switched on."; + #pmstat=$(pactl list | grep "Active Profile" | sed '2p;d' | cut -d ' ' -f 3) + #[ -n "$pmstat" ] && notify-send "Connected" "Bluetooth Device is connected" + 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") + 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) + past_profile=$(echo "$pmstat") + 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 |