diff options
| author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-04-08 03:32:55 +0530 | 
|---|---|---|
| committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-04-08 03:32:55 +0530 | 
| commit | d39ac806a84df1e2a338163a10e0bda2fc73ec83 (patch) | |
| tree | 9a718846547d3fc675a1399cf3f7f3e914ce39b0 /.scripts | |
| parent | f431a55990f3564948eb8988eaf8e7a6bdcddcb7 (diff) | |
.scripts: bluetooth script+4chget executable
Diffstat (limited to '.scripts')
| -rwxr-xr-x[-rw-r--r--] | .scripts/4chget | 0 | ||||
| -rwxr-xr-x | .scripts/bts | 42 | 
2 files changed, 42 insertions, 0 deletions
diff --git a/.scripts/4chget b/.scripts/4chget index 1317824..1317824 100644..100755 --- a/.scripts/4chget +++ b/.scripts/4chget diff --git a/.scripts/bts b/.scripts/bts new file mode 100755 index 0000000..b9424e3 --- /dev/null +++ b/.scripts/bts @@ -0,0 +1,42 @@ +#!/bin/bash +option=$(echo -e "Connect\nDisconnect\nChange profile\nReset pulseaudio"| tofi --prompt-text "Do you wish to connect/disconnect or change soundprofile of your bluetooth device:")  +#Prereq: trust the MAC address +#MAC="11:11:22:ED:08:AD" +MAC="76:67:11:36:64:A2" +#MAC="E4:59:37:44:27:7A" +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 connected" ||  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 disconnected" || notify-send "Unable to disconnect!" ;; + +    "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)" | tofi --prompt-text "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;; +    "Reset pulseaudio") +        ##check for a2dp sink not found error in status command +        pulseaudio --kill && pulseaudio --cleanup-shm && pulseaudio --start;; +esac  | 
