pa: Add sh version
Add POSIX compliant sh version of the pa script.
This commit is contained in:
parent
68319d2b55
commit
71bea304af
10
pa.bash
10
pa.bash
|
@ -10,13 +10,19 @@ function profile {
|
||||||
# If either i3’s button is 1 or the first argument is “switch”, switch profile
|
# If either i3’s button is 1 or the first argument is “switch”, switch profile
|
||||||
if [[ $BLOCK_BUTTON -eq 1 ]] || [ "$1" == "switch" ] ; then
|
if [[ $BLOCK_BUTTON -eq 1 ]] || [ "$1" == "switch" ] ; then
|
||||||
profile
|
profile
|
||||||
if ! [ "$CURRENT_PROFILE" = "iec958-stereo-output" ] ; then
|
if ! [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then
|
||||||
pacmd set-card-profile 0 output:iec958-stereo
|
pacmd set-card-profile 0 output:iec958-stereo
|
||||||
else
|
else
|
||||||
pacmd set-card-profile 0 output:hdmi-stereo-extra2
|
pacmd set-card-profile 0 output:hdmi-stereo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print out current profile
|
# Print out current profile
|
||||||
profile
|
profile
|
||||||
|
if [[ "$CURRENT_PROFILE" == *"iec958"* ]] ; then
|
||||||
|
echo "digital"
|
||||||
|
elif [[ "$CURRENT_PROFILE" == *"hdmi"* ]] ; then
|
||||||
|
echo "hdmi"
|
||||||
|
else
|
||||||
echo "${CURRENT_PROFILE%%-*}"
|
echo "${CURRENT_PROFILE%%-*}"
|
||||||
|
fi
|
||||||
|
|
28
pa.sh
Executable file
28
pa.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue