From 4be0ce58993736c7c0a6a7b9bc11b8bf5a3362cb Mon Sep 17 00:00:00 2001 From: Steven Saus Date: Thu, 17 Feb 2022 16:48:06 -0500 Subject: [PATCH] Added pulse-fzf-autoconf to supplement pulse-autoconf --- pulse-fzf-autoconf | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 pulse-fzf-autoconf diff --git a/pulse-fzf-autoconf b/pulse-fzf-autoconf new file mode 100755 index 0000000..4328a60 --- /dev/null +++ b/pulse-fzf-autoconf @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +############################################################################## +# +# pulse-fzf-autoconf +# By Steven Saus +# (c) 2022; licensed under the MIT license +# +# simply allows quick switching of pulse-autoconf from either fzf or +# from command line switches (e.g. for use with Openbox, etc). +# +# Default presets from pulse-autoconf v 1.5.1 are +# +# preset="EchoCancellation" +# preset="EchoCancellationWithSourcesMix" +# preset="EchoCancellationPlacebo" +# preset="None" +# +# No error-checking is done for direct input +# +# You can find pulse-autoconf at +# https://eomanis.duckdns.org/permshare/pulse-autoconf +# +############################################################################## + +ConfigFile=$HOME/.config/pulse-autoconf/pulse-autoconf.conf + +if [ ! -f "${ConfigFile}" ];then + exit 99 +fi + +if [ -z "$1" ];then + + AllPreset=$(grep "preset=" "${ConfigFile}" | awk -F '"' '{print $2}') + CurrentPreset=$(grep "preset=" "${ConfigFile}" | grep -v -e "^#" | awk -F '"' '{print $2}') + DesiredPreset=$(echo "${AllPreset}" | fzf) +else + DesiredPreset="$1" +fi + +# If they're the same, do nothing. +if [ "${CurrentPreset}" != "${DesiredPreset}" ];then + sed -i "s|preset=\"${CurrentPreset}\"|#preset=\"${CurrentPreset}\"|" "${ConfigFile}" + sed -i "s|#preset=\"${DesiredPreset}\"|preset=\"${DesiredPreset}\"|" "${ConfigFile}" +fi +