added audio output toggle

This commit is contained in:
2025-06-23 15:31:45 +10:00
parent b7f1abf9b2
commit 1c31cceae4
3 changed files with 90 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# Get the ID of the default sink (output device)
default_sink=$(wpctl status 2>/dev/null | awk '/Sinks:/,/Sources:/' | awk '/\*/ {print $3}' | tr -d '.')
if [ -z "$default_sink" ]; then
echo "No default audio output device found"
exit 1
fi
# Get the description or fallback to node.name
device_name=$(wpctl inspect "$default_sink" 2>/dev/null | awk -F '"' '/node.description/ {print $2}')
if [ -z "$device_name" ]; then
device_name=$(wpctl inspect "$default_sink" 2>/dev/null | awk -F '"' '/node.name/ {print $2}')
fi
# Map known device names to labels
case "$device_name" in
"Starship/Matisse HD Audio Controller Analog Stereo")
label="Speakers"
;;
"Yeti Stereo Microphone Analog Stereo")
label="Earphones"
;;
*)
label="$device_name"
;;
esac
# Output the label
echo "$label"