30 lines
800 B
Bash
Executable File
30 lines
800 B
Bash
Executable File
#!/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
|
|
|