diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-09-02 08:44:38 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-09-02 08:44:38 -0500 |
commit | a4373a898e65604f58299c947882f50294dd813f (patch) | |
tree | d07fd4eb4ccf9fef1fa8a73d1160b7174c7c317e /keyboard/sinkswitch | |
parent | 988cadef2c2e51adbfa64da83ec7d25a8de3d924 (diff) | |
download | scripts-a4373a898e65604f58299c947882f50294dd813f.tar.xz scripts-a4373a898e65604f58299c947882f50294dd813f.zip |
various changes over time
Diffstat (limited to 'keyboard/sinkswitch')
-rwxr-xr-x | keyboard/sinkswitch | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/keyboard/sinkswitch b/keyboard/sinkswitch new file mode 100755 index 0000000..3046498 --- /dev/null +++ b/keyboard/sinkswitch @@ -0,0 +1,15 @@ +#!/bin/sh +[ $(hostname) != 'T495' ] && echo "Not T495. Exiting" && exit 1 + +status="$(wpctl status)" + +headphones_sink=$(echo "$status" | grep -m1 'ThinkPad USB-C Dock Gen2 USB Audio Analog Stereo \[vol:' | grep -m1 -o '[0-9]*') +speakers_sink=$( echo "$status" | grep -m1 'Raven/Raven2/Fenghuang HDMI/DP Audio Controller Digital Stereo (HDMI 2) \[vol:' | grep -m1 -o '[0-9]*') + +selected_sink=$(echo "$status" | grep -m1 '\*\s*[0-9]*' | grep -o '[0-9]*') + +case $selected_sink in + $headphones_sink) wpctl set-default $speakers_sink && echo "Switched to speakers" ;; + $speakers_sink) wpctl set-default $headphones_sink && echo "Switched to headphones" ;; + *) echo "Cannot find correct sink. Exiting" && exit 1 ;; +esac |