From 6a2b0f19638035513054d5f101d6d95849d0a0cf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 21 Feb 2026 07:43:46 +0100 Subject: [PATCH] Fix Bluetooth device showing bluez ID instead of friendly name (#4260) Look up device.id first for Bluetooth friendly names, falling back to object.id for non-Bluetooth devices. Also fix conditionals to use [[ ]]. Co-Authored-By: Claude Opus 4.6 --- bin/omarchy-cmd-audio-switch | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-cmd-audio-switch b/bin/omarchy-cmd-audio-switch index 299eeb19..b68aaef4 100755 --- a/bin/omarchy-cmd-audio-switch +++ b/bin/omarchy-cmd-audio-switch @@ -27,9 +27,17 @@ next_sink=$(echo "$sinks" | jq -r ".[$next_sink_index]") next_sink_name=$(echo "$next_sink" | jq -r '.name') next_sink_description=$(echo "$next_sink" | jq -r '.description') -if [ "$next_sink_description" = "(null)" ] || [ "$next_sink_description" = "null" ] || [ -z "$next_sink_description" ]; then - sink_id=$(echo "$next_sink" | jq -r '.properties."object.id"') - next_sink_description=$(wpctl status | grep -E "\s+\*?\s+${sink_id}\." | sed -E 's/^.*[0-9]+\.\s+//' | sed -E 's/\s+\[.*$//') +if [[ $next_sink_description == "(null)" ]] || [[ $next_sink_description == "null" ]] || [[ -z $next_sink_description ]]; then + # For Bluetooth devices, the friendly name is on the Device entry (device.id), not the Sink entry (object.id) + device_id=$(echo "$next_sink" | jq -r '.properties."device.id"') + if [[ $device_id != "null" ]] && [[ -n $device_id ]]; then + next_sink_description=$(wpctl status | grep -E "^\s*│?\s+${device_id}\." | sed -E 's/^.*[0-9]+\.\s+//' | sed -E 's/\s+\[.*$//') + fi + # Fall back to object.id lookup if device.id didn't yield a result + if [[ -z $next_sink_description ]]; then + sink_id=$(echo "$next_sink" | jq -r '.properties."object.id"') + next_sink_description=$(wpctl status | grep -E "\s+\*?\s+${sink_id}\." | sed -E 's/^.*[0-9]+\.\s+//' | sed -E 's/\s+\[.*$//') + fi fi next_sink_volume=$(echo "$next_sink" | jq -r \