arch-packages/discord-launcher.sh

36 lines
1,002 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
2022-12-10 12:07:22 +01:00
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}" ]] && python -c "import capstone; import elftools" &> /dev/null; then
# Patch Krisp binary to ignore signature check
python /usr/share/${name}/krisp-patcher.py "${krisp_bin}"
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 \
"${flags[@]}" "$@"