diff --git a/KIOSK setup/kiosk-session.sh b/KIOSK setup/kiosk-session.sh new file mode 100644 index 0000000..556fa48 --- /dev/null +++ b/KIOSK setup/kiosk-session.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# Kiosk session. Exits when the app exits. + +APP_DIR="/home/ears/Desktop/Kazi/v3/linux/" +APP_CMD="mono program.exe" +DISPLAY_SETUP="/home/ears/rotate.sh" + +LOG_DIR="$HOME/kiosk/logs" +mkdir -p "$LOG_DIR" +SESSION_LOG="$LOG_DIR/session-$(date +%Y%m%d-%H%M%S).log" +ln -sfn "$SESSION_LOG" "$LOG_DIR/current.log" +ls -1t "$LOG_DIR"/session-*.log 2>/dev/null | tail -n +21 | xargs -r rm -f + +exec > >(tee -a "$SESSION_LOG") 2>&1 +echo "=== session start $(date -Is) ===" + +# no blanking, no screensaver, no pointer +cd "$APP_DIR" || { echo "FATAL: $APP_DIR not found"; sleep 20; exit 1; } + +# --- hardware setup, shared with the Xubuntu session --- +if [[ -x "$DISPLAY_SETUP" ]]; then + echo "--- running display-setup.sh ---" + "$DISPLAY_SETUP" +else + echo "WARNING: $DISPLAY_SETUP missing, using fallback" + xset s off; xset s noblank; xset -dpms +fi + +unclutter -idle 0 -root & +matchbox-window-manager -use_titlebar no -use_cursor no & + +cd "$APP_DIR" || { echo "FATAL: $APP_DIR not found"; sleep 20; exit 1; } + +recovery_console() { + echo "=== crash loop, opening recovery console ===" + xterm -fa Monospace -fs 14 -geometry 130x42 -T "kiosk recovery" -e bash -c " + echo 'The app failed to start 3 times in a row.' + echo 'Last 60 lines of $SESSION_LOG:' + echo '--------------------------------------------------' + tail -n 60 '$SESSION_LOG' + echo '--------------------------------------------------' + echo + echo 'Shell below. Type exit to retry the app.' + exec bash + " +} + +fails=0 +while true; do + started=$SECONDS + $APP_CMD + code=$? + ran=$(( SECONDS - started )) + echo "=== app exited $code after ${ran}s ===" + + # Clean exit (the Close button) ends the kiosk session. + if (( code == 0 )); then + echo "=== clean exit, leaving kiosk ===" + exit 0 + fi + + if (( ran < 20 )); then (( fails++ )); else fails=1; fi + if (( fails >= 3 )); then + fails=0 + recovery_console + fi + sleep 2 +done diff --git a/KIOSK setup/kiosk-start.sh b/KIOSK setup/kiosk-start.sh new file mode 100644 index 0000000..76628da --- /dev/null +++ b/KIOSK setup/kiosk-start.sh @@ -0,0 +1,16 @@ +#!/bin/bash +LOG_DIR="$HOME/kiosk/logs" +mkdir -p "$LOG_DIR" + +VT=$(fgconsole 2>/dev/null) || { + echo "Not on a text console. Press Ctrl+Alt+F3, log in there, and run this again." + exit 1 +} + +echo "Starting kiosk on VT $VT. Ctrl+Alt+F7 returns to the desktop." +sleep 1 + +startx "$HOME/kiosk/kiosk-session.sh" -- :1 "vt${VT}" -keeptty -nocursor \ + >> "$LOG_DIR/startx.log" 2>&1 + +echo "Kiosk session ended." diff --git a/KIOSK setup/rotate.sh b/KIOSK setup/rotate.sh new file mode 100644 index 0000000..670afc5 --- /dev/null +++ b/KIOSK setup/rotate.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +sleep 3 + +MATRIX="0 1 0 -1 0 1 0 0 1" +ROTATION="right" + +OUT=$(xrandr | awk '/ connected/{print $1; exit}') +TOUCH="SIS0457:00 0457:11ED" + +#DISPLAY +[ -n "$OUT" ] && xrandr --output "$OUT" --rotate "$ROTATION" + +#Touchscreen +xinput list --name-only | grep -qxF "$TOUCH" && xinput set-prop "$TOUCH" "Coordinate Transformation Matrix" $MATRIX + +# Disable Blanking and screensaver +xset s off +xset s noblank +xset -dpms