configure_audio() { local sudo=$(command -v sudo) sudo="${sudo:-doas}" local audioProvider if pgrep pipewire &> /dev/null ; then audioProvider="pipewire" elif pgrep pulse &> /dev/null ; then audioProvider="pulseaudio" else audioProvider="alsa" fi lsmod | grep snd_aloop || $sudo modprobe snd_aloop cardNumber="$(aplay -l |grep -P '^card \d+: Loopback' |head -n1 | cut -d\ -f2 | cut -d: -f1)" if ! [[ "$cardNumber" =~ ^[0-9]+$ ]] ; then dialog --backtitle "Linux Game Manager" \ --msgbox "The loopback module card number was not properly set.\nThis could mean that you failed to type your password for root privileges, or something else has gone wrong.\n If you think root privileges were succesfully obtained, please report this to the maintainers. Mention the card value: ${cardNumber}." -1 -1 exit 1 fi alsaloop -C hw:${cardNumber},1,0 -P default &> /dev/null & } configure_webkit() { local webkitPath local sudo=$(command -v sudo) sudo="${sudo:-doas}" # First check if it's already properly set up [[ -d /usr/libexec/webkit2gtk-4.0 ]] && return 0 webkitPath=$(find /usr/lib* /usr/local/lib* -type d -name 'webkit2gtk-4.0' 2>/dev/null | head -n1) if [[ -z "${webkitPath}" ]]; then dialog --backtitle "Linux Game manager" \ --msgbox "Error: webkit2gtk-4.0 not found. Please install webkit2gtk package for your distribution." -1 -1 exit 1 fi # Create libexec directory if it doesn't exist if [[ ! -d /usr/libexec ]]; then if ! $sudo mkdir -p /usr/libexec; then echo "Error: Failed to create /usr/libexec directory" exit 1 fi fi if ! $sudo ln -s "${webkitPath}" /usr/libexec/webkit2gtk-4.0; then echo "Error: Failed to create symlink for webkit2gtk-4.0" exit 1 fi } set_sound_device() { if ! grep -q 'set s_device' "${installPath}/AudioQuake/data/id1/config.cfg" ; then echo "set s_device hw:${cardNumber},0,0" >> "${installPath}/AudioQuake/data/id1/config.cfg" else sed -E -i 's/set s_device/set s_device hw:${cardNumber},0,0/g' "${installPath}/AudioQuake/data/id1/config.cfg" fi if ! grep -q 'set s_device' "${installPath}/AudioQuake/data/oq/config.cfg" ; then echo "set s_device hw:${cardNumber},0,0" >> "${installPath}/AudioQuake/data/oq/config.cfg" else sed -E -i 's/set s_device/set s_device hw:${cardNumber},0,0/g' "${installPath}/AudioQuake/data/oq/config.cfg" fi } trap 'pkill -P $$' EXIT configure_audio configure_webkit set_sound_device pushd "${installPath}/AudioQuake" ./AudioQuake