2024-05-15 19:42:02 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-09-15 19:43:31 +02:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2022-12-10 12:07:22 +01:00
|
|
|
name=@PKGNAME@
|
2024-05-15 19:42:02 +02:00
|
|
|
ver=@PKGVER@
|
2022-09-15 19:43:31 +02:00
|
|
|
electron=@ELECTRON@
|
2024-05-15 19:42:02 +02:00
|
|
|
krisp_b2=@KRISPB2@
|
2022-09-15 19:43:31 +02:00
|
|
|
|
|
|
|
declare -a flags
|
2024-05-15 19:42:02 +02:00
|
|
|
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
|
2022-09-15 19:43:31 +02:00
|
|
|
|
2024-05-15 19:42:02 +02:00
|
|
|
if [[ -r "${flags_file}" ]]; then
|
|
|
|
mapfile -t < "${flags_file}"
|
2022-09-15 19:43:31 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for line in "${MAPFILE[@]}"; do
|
2024-05-15 19:42:02 +02:00
|
|
|
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]] && [[ -n "${line}" ]]; then
|
|
|
|
flags+=("${line}")
|
|
|
|
fi
|
2022-09-15 19:43:31 +02:00
|
|
|
done
|
|
|
|
|
2024-05-15 19:42:02 +02:00
|
|
|
exec /usr/bin/${electron} \
|
|
|
|
/usr/share/${name}/resources/app.asar \
|
|
|
|
--ozone-platform-hint=auto \
|
|
|
|
"${flags[@]}" "$@"
|