diff options
author | Vinny Meller | 2021-10-04 23:35:46 -0500 |
---|---|---|
committer | Vinny Meller | 2021-10-04 23:35:46 -0500 |
commit | 4049f43f202a3dac0032405d1c053b5cae8a40e4 (patch) | |
tree | 3fe8d32a3972ff8d03efcc9734dc8d0b23bcea4b | |
parent | e2a87bfc1c1108a08a1fbbbc7287d95c4a3eb1f6 (diff) | |
download | aur-4049f43f202a3dac0032405d1c053b5cae8a40e4.tar.gz |
moved sink inputs to default sink
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rwxr-xr-x | pulseaudio-nextsink | 15 |
3 files changed, 17 insertions, 2 deletions
@@ -1,6 +1,6 @@ pkgbase = pulseaudio-nextsink pkgdesc = Swaps audio sink to the next in the list via pactl - pkgver = 1.0.0 + pkgver = 2.0.0 pkgrel = 1 url = https://www.github.com/vinnymeller/pulseaudio-nextsink arch = x86_64 @@ -1,6 +1,6 @@ # Maintainer: Vinny Meller (vinnymeller@gmail.com) pkgname="pulseaudio-nextsink" -pkgver="1.0.0" +pkgver="2.0.0" pkgrel="1" pkgdesc="Swaps audio sink to the next in the list via pactl" arch=("x86_64") diff --git a/pulseaudio-nextsink b/pulseaudio-nextsink index 14494d5f1f43..4267bb9150e6 100755 --- a/pulseaudio-nextsink +++ b/pulseaudio-nextsink @@ -2,6 +2,19 @@ # Iterates through the list of available sinks from pactl # Made to be used with a hotkey to quickly swap between outputs. Therefore takes no inputs. +# Function takes the sink that we are making default and moves all inputs to that sink +function change_sink_inputs_to_default_sink_num { + readarray -t all_sink_inputs <<<"$(pacmd list-sink-inputs | grep index:)" + for sink_input in "${all_sink_inputs[@]}" + do + sink_input_arr=( $sink_input ) + index_num=${sink_input_arr[1]} # index 0 of the array should be "index:" and next the number we want + pactl move-sink-input $index_num $1 + echo "Moved sink input $index_num to sink $1" + done +} + + default_sink_line=$(pactl list short sinks | grep $(pactl get-default-sink)) default_sink_arr=( $default_sink_line ) default_sink_num=${default_sink_arr[0]} # The number of the currently default sink. Not using the whole line because they can change frequently @@ -15,6 +28,7 @@ do if [ "$last_sink_active" = true ]; then pactl set-default-sink $sink_num echo "Set pulse default sink to number $sink_num" + change_sink_inputs_to_default_sink_num "$sink_num" exit 0 fi if [ "$default_sink_num" = "$sink_num" ]; then @@ -27,4 +41,5 @@ first_sink_arr=( $first_sink ) first_sink_num=${first_sink_arr[0]} pactl set-default-sink $first_sink_num echo "Set pulse default sink to number $first_sink_num" +change_sink_inputs_to_default_sink_num "$first_sink_num" exit 0 |