You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
2 years ago
|
#!/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
|
||
|
|