From ea829c596e82af20fabc4e6f1462469fa57cae04 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 27 Mar 2026 16:13:58 +0100 Subject: [PATCH] fix: reduce phone penalty to 100s, fix shutdown guard race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PHONE_PENALTY_DELAY_PRODUCTION: 600 → 100 seconds - adjust_shutdown_schedule.sh: write canonical copy before watched config to prevent shutdown-schedule-guard.path from restoring stale values --- python_pkg/screen_locker/_constants.py | 2 +- .../screen_locker/adjust_shutdown_schedule.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python_pkg/screen_locker/_constants.py b/python_pkg/screen_locker/_constants.py index 740b63b..acc0e58 100644 --- a/python_pkg/screen_locker/_constants.py +++ b/python_pkg/screen_locker/_constants.py @@ -6,7 +6,7 @@ from pathlib import Path SICK_LOCKOUT_SECONDS = 120 # 2 minutes wait when sick PHONE_PENALTY_DELAY_DEMO = 10 -PHONE_PENALTY_DELAY_PRODUCTION = 600 +PHONE_PENALTY_DELAY_PRODUCTION = 100 ADB_TIMEOUT = 15 STRONGLIFTS_DB_REMOTE = ( "/data/data/com.stronglifts.app/databases/StrongLifts-Database-3" diff --git a/python_pkg/screen_locker/adjust_shutdown_schedule.sh b/python_pkg/screen_locker/adjust_shutdown_schedule.sh index acbdba1..ee2234d 100755 --- a/python_pkg/screen_locker/adjust_shutdown_schedule.sh +++ b/python_pkg/screen_locker/adjust_shutdown_schedule.sh @@ -72,16 +72,16 @@ MORNING_END_HOUR=$3 chattr -i "$CONFIG_FILE" 2>/dev/null || true chattr -i "$CANONICAL_FILE" 2>/dev/null || true -# Write new config -echo "$NEW_CONFIG" > "$CONFIG_FILE" +# Write canonical copy FIRST (before the watched config) to avoid +# a race with shutdown-schedule-guard.path which triggers on CONFIG_FILE +# changes and restores from CANONICAL_FILE. echo "$NEW_CONFIG" > "$CANONICAL_FILE" - -# Set permissions -chmod 644 "$CONFIG_FILE" chmod 644 "$CANONICAL_FILE" - -# Re-apply immutable attributes -chattr +i "$CONFIG_FILE" || echo "Warning: Could not set immutable on $CONFIG_FILE" >&2 chattr +i "$CANONICAL_FILE" || echo "Warning: Could not set immutable on $CANONICAL_FILE" >&2 +# Now write the watched config — guard will see content matches canonical +echo "$NEW_CONFIG" > "$CONFIG_FILE" +chmod 644 "$CONFIG_FILE" +chattr +i "$CONFIG_FILE" || echo "Warning: Could not set immutable on $CONFIG_FILE" >&2 + echo "Shutdown schedule updated: Mon-Wed=${1}:00, Thu-Sun=${2}:00, Morning end=${3}:00"