Multiple scripts that are useful but don't deserve their own repository.
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.
multiple_scripts/pulse-fzf-autoconf

73 lines
2.5 KiB

#!/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). Example OpenBox
# menu at the end of this file.
#
# 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
CurrentPreset=$(grep "preset=" "${ConfigFile}" | grep -v -e "^#" | awk -F '"' '{print $2}')
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
###############################################################################
# Example Openbox Menu
#
# <menu id="pa-ac" label="pa-auto">
# <item label="None">
# <action name="Execute">#
# <execute> #
# /home/steven/bin/pulse-fzf-autoconf None#
# </execute>#
# </action>#
# </item>#
# <item label="Echo Cancellation">#
# <action name="Execute">#
# <execute> #
# /home/steven/bin/pulse-fzf-autoconf EchoCancellation#
# </execute>#
# </action>#
# </item>#
# <item label="Mixing">#
# <action name="Execute">#
# <execute> #
# /home/steven/bin/pulse-fzf-autoconf EchoCancellationWithSourcesMix#
# </execute>#
# </action>#
# </item>#
# </menu>#