27 lines
1.1 KiB
Bash
27 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Explicit local development launcher; requires systemd 254+ and cgroup v2.
|
|
set -euo pipefail
|
|
if (( $# == 0 )); then
|
|
echo 'Usage: bash tests/run-delegated-reader.sh /absolute/path/to/cthulhu [reader options]' >&2
|
|
exit 2
|
|
fi
|
|
if [[ $1 != /* || ! -x $1 ]]; then
|
|
echo 'The reader executable must be an absolute executable path.' >&2
|
|
exit 2
|
|
fi
|
|
# Preserve desktop/backend locations without importing the whole environment
|
|
# into the persistent user manager. These values apply only to this service.
|
|
environment=()
|
|
for name in DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS AT_SPI_BUS_ADDRESS \
|
|
XDG_RUNTIME_DIR XDG_SESSION_TYPE XDG_SESSION_DESKTOP XDG_DATA_HOME \
|
|
XDG_CONFIG_HOME XDG_CACHE_HOME LANG LANGUAGE LC_ALL \
|
|
SPEECHD_ADDRESS SPEECHD_SOCKET; do
|
|
if [[ -v $name ]]; then
|
|
environment+=("--setenv=$name=${!name}")
|
|
fi
|
|
done
|
|
exec systemd-run --user --wait --pipe --collect --same-dir \
|
|
--property='Delegate=cpu memory pids' --property=DelegateSubgroup=reader \
|
|
--property=KillMode=control-group --property=TimeoutStopSec=10s \
|
|
"${environment[@]}" -- "$@"
|