#!/bin/sh
lib=$(cd "$(dirname "$(readlink -f "$0")")/../lib" && pwd)
export LD_LIBRARY_PATH="$lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
if [ -n "${OMBAK_OS_FOREGROUND:-}" ]; then
  exec "$lib/ombak-os" "$@"
fi
# A caller that opens a link (xdg-open under npm login, gh auth, git) waits for this launcher
# and for its pipes to close: stay attached and it hangs for as long as Ombak runs.
if command -v setsid >/dev/null 2>&1; then
  exec setsid -f "$lib/ombak-os" "$@" </dev/null >/dev/null 2>&1
fi
"$lib/ombak-os" "$@" </dev/null >/dev/null 2>&1 &
