#!/bin/sh
# Sign PDFs with SignerX from the file manager ("Open with" / scripts) or the shell: signerx-sign file.pdf ...
# Uses the per-user runtime SignerX installs on first start, else the packaged one.
APP="$HOME/SignerX/app/SignerX-Api.dll"
[ -f "$APP" ] || APP="/opt/signerx/share/runtime/app/SignerX-Api.dll"
# make sure the tray app (and with it the signing service) is running
if ! pgrep -x SignerX >/dev/null 2>&1; then
    nohup /opt/signerx/bin/SignerX --autostart >/dev/null 2>&1 &
    sleep 3
fi
exec dotnet "$APP" --sign "$@"
