arch-packages/discord-launcher.sh
Manuel f1b9162b23
upgpkg: discord 0.0.54-2: refactor, fix autostart, add deps, use wayland
* Slightly refactor PKGBUILD
* Fix autostart desktop file
* Add optional dependency used in official arch package
* Include patch to allow Krisp noise suppression support
* Add install file to inform user about this change
* Use Wayland instead of Xwayland in a Wayland session by setting
  Electron flag `ozone-platform-hint` to auto (default is X11)
2024-05-15 19:42:02 +02:00

39 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
name=@PKGNAME@
ver=@PKGVER@
electron=@ELECTRON@
krisp_b2=@KRISPB2@
declare -a flags
declare 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 hash rizin &> /dev/null && [[ "${PATCH_KRISP}" == true ]]; then
# Patch Krisp binary to ignore signature check
if [[ -w "${krisp_bin}" && $(b2sum "${krisp_bin}" | head -c 128) == $krisp_b2 ]]; then
addr=$(rz-find -x '4881ec00010000' "${krisp_bin}" | head -n1)
rizin -q -w -c "s $addr + 0x30 ; wao nop" "${krisp_bin}" &> /dev/null
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 \
"${flags[@]}" "$@"