#!/usr/bin/env sh
set -eu

SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
ROOT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)

export SALECULATOR_HOME="${SALECULATOR_HOME:-$ROOT_DIR}"
export SALECULATOR_CONFIG="${SALECULATOR_CONFIG:-$HOME/Saleculator.properties}"

if command -v xset >/dev/null 2>&1; then
    xset -dpms || true
    xset s off || true
    xset s noblank || true
fi

if command -v unclutter >/dev/null 2>&1; then
    unclutter -idle 0.5 -root >/dev/null 2>&1 &
fi

cd "$SALECULATOR_HOME"
exec "$SALECULATOR_HOME/scripts/run.sh" "$SALECULATOR_CONFIG"
