Added hdmi toggle script
This commit is contained in:
parent
a6c2130926
commit
dd62a1ab07
29
togglehdmiaudio.sh
Executable file
29
togglehdmiaudio.sh
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Toggle between HDMI and Analog
|
||||||
|
# Find out current RUNNING sink
|
||||||
|
currentSink=$(pactl list short sinks | grep 'RUNNING' | awk '{print$2}')
|
||||||
|
sink=NULL
|
||||||
|
|
||||||
|
# Then find the first hdmi or analog sink
|
||||||
|
if [[ $currentSink == *"hdmi"* ]]; then
|
||||||
|
sink=$(pactl list short sinks | awk '{print$2}' | grep 'analog' | sed -n '1p')
|
||||||
|
else
|
||||||
|
sink=$(pactl list short sinks | awk '{print$2}' | grep 'hdmi' | sed -n '1p')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exit if there is no sink :(
|
||||||
|
if [ -z $sink ]; then
|
||||||
|
echo "Error! Could not find sink to toggle to!"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set outputs
|
||||||
|
echo "setting default sink to $sink"
|
||||||
|
pactl set-default-sink "$sink"
|
||||||
|
pactl list short sink-inputs|while read stream; do
|
||||||
|
streamId=$(echo $stream|cut '-d ' -f1)
|
||||||
|
echo "moving stream $streamId"
|
||||||
|
pactl move-sink-input "$streamId" "$sink"
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user