added audio output toggle
This commit is contained in:
33
.config/polybar/audio_output_status.sh
Executable file
33
.config/polybar/audio_output_status.sh
Executable 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"
|
||||
|
||||
Reference in New Issue
Block a user