#!/bin/bash
set -e
HERE="$(dirname "$(readlink -f "${0}")")"
RT="${HERE}/usr/lib/titletimer/rt"
SRC="${HERE}/usr/lib/titletimer/src"

# Fully self-contained: our own Python + GTK4 + gtk4-layer-shell + PyGObject
# + pycairo + evdev + python-xlib + ld.so/libc, none of it from the host.
# Needed on targets like NixOS with no FHS python3/GTK4 on PATH at all.
export PYTHONHOME="${RT}/python-lib"
export PYTHONPATH="${RT}:${RT}/python-lib/python3.13:${RT}/python-lib/python3.13/lib-dynload:${SRC}"
export GI_TYPELIB_PATH="${RT}/typelibs"
export LD_LIBRARY_PATH="${RT}/lib"
export GDK_BACKEND=x11

exec "${RT}/lib/ld-linux-x86-64.so.2" --library-path "${RT}/lib" "${RT}/bin/python3" -m titletimer "$@"
