Cleanup repo + harden offline install and watchdog
Repo hygiene: - Remove dead scripts (.wait-for-display, .display-keepalive, .keep-screen-alive) - Remove stale backup/scratch (install.sh.bak, New.txt, stale .pyc) - Stop tracking machine-specific/generated state (config/app_config.json, playlists/server_playlist.json, src/player_auth.json, generated launchers) - Prune duplicate wheel versions (one per package) - Reorganize working_files -> dev/, dev/tests/, documentation/dev-notes/, scripts/ - Extend .gitignore; fix no-op rules in repo/.gitignore Offline install (install.sh): - Non-fatal system-dep step; per-package apt retry; .deb bundle install - Skip pip self-upgrade offline; guard online fallbacks behind connectivity probe - Dependency-free fetch_url (curl/wget/urllib); --no-reboot flag - Fix corrupted literal backslash-bang escapes (shebangs, test -f, banner) - Idempotent cron install (no more stacked @reboot lines) Autostart / watchdog: - start.sh: single-instance flock lock (.player_watchdog.lock) acquired only after a display is confirmed, preventing parallel watchdogs - Set XDG_RUNTIME_DIR when missing; exit early if headless - run_player.sh: activate .venv; stop_player.sh: clear lock file
This commit is contained in:
@@ -59,6 +59,13 @@ load_user_environment() {
|
||||
# Fallback: detect display manually
|
||||
log_message "Falling back to manual display detection..."
|
||||
|
||||
# Ensure XDG_RUNTIME_DIR is set. Wayland clients (and Kivy) need it, and a
|
||||
# cron-launched instance may not have it. Default to the standard location.
|
||||
if [ -z "$XDG_RUNTIME_DIR" ]; then
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
log_message "Set XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
|
||||
fi
|
||||
|
||||
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
|
||||
# Try to detect Wayland display
|
||||
if [ -S "/run/user/$(id -u)/wayland-0" ]; then
|
||||
@@ -96,8 +103,27 @@ load_user_environment() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Load the user environment early
|
||||
load_user_environment
|
||||
# Load the user environment early. If there is no usable display, exit WITHOUT
|
||||
# taking the lock — otherwise a headless instance (e.g. cron before login) would
|
||||
# block the real desktop-autostart instance from ever running.
|
||||
if ! load_user_environment; then
|
||||
log_message "No display server available — exiting so another instance can start"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# Single-instance guard (prevents parallel watchdogs)
|
||||
# ============================================================
|
||||
# Only ONE watchdog may run at a time. If XDG autostart, the cron fallback, and
|
||||
# a manual start all fire, the first one to reach this point wins; every other
|
||||
# instance exits immediately instead of spawning a second player.
|
||||
LOCK_FILE="$SCRIPT_DIR/.player_watchdog.lock"
|
||||
exec 200>"$LOCK_FILE"
|
||||
if ! flock -n 200; then
|
||||
log_message "Another watchdog is already running (lock: $LOCK_FILE) — exiting"
|
||||
exit 0
|
||||
fi
|
||||
log_message "Single-instance lock acquired: $LOCK_FILE"
|
||||
|
||||
# Function to configure display output to Full HD (1920x1080)
|
||||
configure_display_resolution() {
|
||||
|
||||
Reference in New Issue
Block a user