mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 3426b7b645dbaeb8822af0f67ff3f1ed534e1c80
parent 194a5b110fd489992255af0dfd23428f02a3b2a7
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat, 31 Oct 2015 11:11:54 +0100

pulseaudio cli

Diffstat:
pals | 7+++++++
palsi | 9+++++++++
pamsi | 10++++++++++
paswitch | 23+++++++++++++++++++++++
4 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/pals b/pals @@ -0,0 +1,7 @@ +#!/bin/bash + +# get pulseaudio sinks, grepping on $1 + +pacmd list-sinks | grep -E 'index:|name:' | paste -d' ' - - | + sed 's/\*/ /' | grep -i "$1" | cut -d' ' -f6,8,9- + diff --git a/palsi b/palsi @@ -0,0 +1,9 @@ +#!/bin/bash + +# list pulseaudio sink input, client, client string, grepping on $ + +pacmd list-sink-inputs | + grep -E 'index:|client:' | paste -d" " - - | + grep -i "$1" | cut -d' ' -f6,8,9- + + diff --git a/pamsi b/pamsi @@ -0,0 +1,10 @@ +#!/bin/bash + +# move stdin sink inputs to $1 + +while read l +do + ID=$(echo "$l" | awk '{print $1}') + pacmd move-sink-input "$ID" "$1" +done + diff --git a/paswitch b/paswitch @@ -0,0 +1,23 @@ +#!/bin/bash + +# search for a sink called "$1", set it as default and move everything to it + +RES=$(pals "$1" | awk '{print $1}') +NRES=$(echo "$RES" | wc -l) +if [ $NRES -lt 1 ] +then + echo "no such sink found, here are the sinks:" + pals + exit 1 +fi +if [ $NRES -gt 1 ] +then + echo "multiple sinks found, be more precise:" + pals "$1" + exit 1 +fi + +palsi | pamsi "$RES" + +pacmd set-default-sink "$RES" +