From bce233a4370cd8a1d5f50dc36aa47b220df89c16 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Sun, 20 Nov 2022 19:08:10 -0800 Subject: bt script: added connect --- polybar/.config/polybar/bt.sh | 13 ++++++++++++- polybar/.config/polybar/config | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'polybar') diff --git a/polybar/.config/polybar/bt.sh b/polybar/.config/polybar/bt.sh index 177932b..3f3b6ec 100755 --- a/polybar/.config/polybar/bt.sh +++ b/polybar/.config/polybar/bt.sh @@ -3,7 +3,6 @@ bluetooth_print() { bluetoothctl | while read -r; do if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then - # printf 'on' devices_paired=$(bluetoothctl devices | grep Device | cut -d ' ' -f 2) counter=0 @@ -54,10 +53,22 @@ bluetooth_toggle() { fi } +bluetooth_connect() { + if bluetoothctl show | grep -q "Powered: yes"; then + devices_paired=$(bluetoothctl devices | grep Device | cut -d ' ' -f 2) + echo "$devices_paired" | while read -r line; do + bluetoothctl connect "$line" >> /dev/null + done + fi +} + case "$1" in --toggle) bluetooth_toggle ;; + --connect) + bluetooth_connect + ;; *) bluetooth_print ;; diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 425e225..72e4c65 100755 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -187,7 +187,8 @@ bar-progress-empty = ─ type = custom/script exec = ~/.config/polybar/bt.sh tail = true -click-left = ~/.config/polybar/bt.sh --toggle & +click-left = ~/.config/polybar/bt.sh --connect & +click-right = ~/.config/polybar/bt.sh --toggle & format = tooth