From df361218f99b1f63ce1d0c53a1948ed738561a25 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Fri, 15 Aug 2025 11:10:22 +0200 Subject: [PATCH] fixed the pixelbuds script --- waybar/config.jsonc | 1 + waybar/scripts/pixelbuds_pro_control.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/waybar/config.jsonc b/waybar/config.jsonc index c840d27..7fcdb6c 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -115,6 +115,7 @@ "interval": 5, "on-click": "~/.config/waybar/scripts/pixelbuds_pro_control.sh connect", "on-click-right": "~/.config/waybar/scripts/pixelbuds_pro_control.sh disconnect", + "on-click-middle": "~/.config/waybar/scripts/pixelbuds_pro_control.sh cycle_anc" }, "custom/audio-output": { "format": "{}", diff --git a/waybar/scripts/pixelbuds_pro_control.sh b/waybar/scripts/pixelbuds_pro_control.sh index 44a4500..0525128 100755 --- a/waybar/scripts/pixelbuds_pro_control.sh +++ b/waybar/scripts/pixelbuds_pro_control.sh @@ -71,16 +71,22 @@ if bluetoothctl info "$MAC_ADDRESS" | grep -q "Connected: yes"; then # Handle click actions passed from Waybar. case "$1" in cycle_anc) + current_mode=$(pbpctrl get anc 2>/dev/null) - if [[ "$current_mode" == "active" ]]; then - pbpctrl set anc aware - else - pbpctrl set anc active - fi - sleep 0.1 - ;; - toggle_anc_off) - pbpctrl set anc off + next_mode="" + case "$current_mode" in + active) + next_mode="aware" + ;; + aware) + next_mode="off" + ;; + off) + next_mode="active" + ;; + esac + + pbpctrl set anc "$next_mode" sleep 0.1 ;; connect)