Last active
August 10, 2020 06:13
-
-
Save frostworx/2a1a84ea8098ddc207cc9f54793f5446 to your computer and use it in GitHub Desktop.
little (hotkey) script which toggles audio output between VR HMD headphones and regular speakers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function PACtl { | |
LC_ALL=C /usr/bin/pactl "$@" | |
} | |
function getAvailablePAProfiles { | |
PACtl list | grep -E 'output.*stereo.*HDMI.*yes' | cut -d':' -f1,2 | awk '{$1=$1};1' | |
} | |
function setActive { | |
PACtl set-card-profile 0 "$1" | |
} | |
PROF1="$(getAvailablePAProfiles | head -n1)" | |
PROF2="$(getAvailablePAProfiles | tail -n1)" | |
ACTIVE_PROF="$(PACtl list | grep -E 'Active Profile.*output' | awk -F ': ' '{print $2}')" | |
if [ "$ACTIVE_PROF" == "$PROF1" ] ; then | |
setActive "$PROF2" | |
else | |
setActive "$PROF1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment