diff --git a/pa.bash b/pa.bash index ffc808f..7ecd045 100755 --- a/pa.bash +++ b/pa.bash @@ -10,13 +10,19 @@ function profile { # If either i3’s button is 1 or the first argument is “switch”, switch profile if [[ $BLOCK_BUTTON -eq 1 ]] || [ "$1" == "switch" ] ; then profile - if ! [ "$CURRENT_PROFILE" = "iec958-stereo-output" ] ; then + if ! [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then pacmd set-card-profile 0 output:iec958-stereo else - pacmd set-card-profile 0 output:hdmi-stereo-extra2 + pacmd set-card-profile 0 output:hdmi-stereo fi fi # Print out current profile profile -echo "${CURRENT_PROFILE%%-*}" +if [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then + echo "digital" +elif [[ "$CURRENT_PROFILE" == *"hdmi"* ]] ; then + echo "hdmi" +else + echo "${CURRENT_PROFILE%%-*}" +fi diff --git a/pa.sh b/pa.sh new file mode 100755 index 0000000..8c8d9bc --- /dev/null +++ b/pa.sh @@ -0,0 +1,28 @@ +#!/bin/sh + + +# Detect current profile +profile() { + CURRENT_PROFILE=$(LC_ALL=C pactl list sinks | grep -i "active port" | cut -d " " -f 3) +} + + +# If either i3’s button is 1 or the first argument is “switch”, switch profile +if [[ $BLOCK_BUTTON -eq 1 ]] || [ "$1" == "switch" ] ; then + profile + if ! [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then + pacmd set-card-profile 0 output:iec958-stereo + else + pacmd set-card-profile 0 output:hdmi-stereo + fi +fi + +# Print out current profile +profile +if [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then + echo "digital" +elif [[ "$CURRENT_PROFILE" == *"hdmi"* ]] ; then + echo "hdmi" +else + echo "${CURRENT_PROFILE%%-*}" +fi