arch-packages/discord-launcher.sh
Zoddo 6d5437d3af
upgpkg: discord 0.0.94-2: Upgrade again to electron36 with workaround for GTK bug
Until the bug is fixed upstream, we force Discord to run on gtk3, as per the
recommendation in the upstream issue:
https://github.com/electron/electron/issues/46538#issuecomment-2790356082
2025-05-15 23:48:43 +02:00

39 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
name=@PKGNAME@
ver=@PKGVER@
electron=@ELECTRON@
declare -a flags
declare -l PATCH_KRISP
[[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/${name}.conf" ]] && source "${XDG_CONFIG_HOME:-$HOME/.config}/${name}.conf"
flags_file="${XDG_CONFIG_HOME:-$HOME/.config}/${name}-flags.conf"
krisp_bin="${DISCORD_USER_DATA_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/${name}}/${ver}/modules/${name}_krisp/${name}_krisp.node"
if [[ "${PATCH_KRISP:-}" == true ]] && [[ -w "${krisp_bin}" ]]; then
if hash python &> /dev/null && python -c 'import capstone; import elftools' &> /dev/null; then
# Patch Krisp binary to ignore signature check
echo -n 'Running Krisp patcher... '
python /usr/share/${name}/krisp-patcher.py "${krisp_bin}"
fi
fi
if [[ -r "${flags_file}" ]]; then
mapfile -t < "${flags_file}"
fi
for line in "${MAPFILE[@]}"; do
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]] && [[ -n "${line}" ]]; then
flags+=("${line}")
fi
done
exec /usr/bin/${electron} \
/usr/share/${name}/resources/app.asar \
--ozone-platform-hint=auto \
--gtk-version=3 \ # Workaround for bug in electron36: https://github.com/electron/electron/issues/46538#issuecomment-2790356082
"${flags[@]}" "$@"