From efa00487313c6b366487715339529272452c2583 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 7 Jun 2020 03:16:43 +0300 Subject: [PATCH] Feat(PulseAudio): Get the default sink dynamically --- audio/pa-mic-off | 2 +- audio/pa-mic-on | 2 +- audio/pa-speaker | 2 +- audio/pa-volume | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/pa-mic-off b/audio/pa-mic-off index 19fb613..a16bce6 100755 --- a/audio/pa-mic-off +++ b/audio/pa-mic-off @@ -1,6 +1,6 @@ #! /bin/sh -default_sink=`cat "$HOME"/.config/pulse/default` +default_sink=`pactl list sinks | awk '/Name:/ {print $2; exit}'` default_source=`echo $default_sink | sed s/output/input/` pactl set-source-mute $default_source 1 && diff --git a/audio/pa-mic-on b/audio/pa-mic-on index d626128..51f76bb 100755 --- a/audio/pa-mic-on +++ b/audio/pa-mic-on @@ -1,6 +1,6 @@ #! /bin/sh -default_sink=`cat "$HOME"/.config/pulse/default` +default_sink=`pactl list sinks | awk '/Name:/ {print $2; exit}'` default_source=`echo $default_sink | sed s/output/input/` pactl set-card-profile 0 $default_source && diff --git a/audio/pa-speaker b/audio/pa-speaker index 4624574..fbfb7e3 100755 --- a/audio/pa-speaker +++ b/audio/pa-speaker @@ -1,6 +1,6 @@ #! /bin/sh -default_sink=`cat "$HOME"/.config/pulse/default` +default_sink=`pactl list sinks | awk '/Name:/ {print $2; exit}'` "`dirname \"$0\"`"/pa-kill sleep 1 diff --git a/audio/pa-volume b/audio/pa-volume index 3e7507f..90c5acf 100755 --- a/audio/pa-volume +++ b/audio/pa-volume @@ -2,7 +2,7 @@ # From http://crunchbanglinux.org/forums/topic/11392/pulseaudio-volume-control-with-media-keys/ declare -i CURVOL=`cat ~/.config/pulse/volume` #Reads in the current volume -default_sink=`cat ~/.config/pulse/default` +default_sink=`pactl list sinks | awk '/Name:/ {print $2; exit}'` if [[ $1 == "increase" ]] then -- 2.39.5