From 8998883a6c04b3325bf4f3d462c9ead755e0ce76 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 15 Mar 2026 19:15:38 +0100 Subject: [PATCH] feat: add auto-close suspension for digital wellbeing Add is_autoclose_suspended() function that checks for a per-app suspend file dated today. When suspended, launches the app directly without the auto-close timer via exec. --- .../block_compulsive_opening.sh | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/linux_configuration/scripts/digital_wellbeing/block_compulsive_opening.sh b/linux_configuration/scripts/digital_wellbeing/block_compulsive_opening.sh index a82f3377..e2e5dfdf 100755 --- a/linux_configuration/scripts/digital_wellbeing/block_compulsive_opening.sh +++ b/linux_configuration/scripts/digital_wellbeing/block_compulsive_opening.sh @@ -175,12 +175,38 @@ kill_app() { pkill -9 -f "$real_binary" 2>/dev/null || true } +# Check if auto-close is suspended for an app today +is_autoclose_suspended() { + local app="$1" + local today + today=$(date '+%Y-%m-%d') + local suspend_file="$STATE_DIR/${app}.suspend-autoclose" + + if [[ -f $suspend_file ]]; then + local suspend_date + suspend_date=$(cat "$suspend_file" 2>/dev/null || echo "") + if [[ $suspend_date == "$today" ]]; then + return 0 # Suspended for today + else + # Stale suspend file, clean up + rm -f "$suspend_file" + fi + fi + return 1 +} + # Launch app with auto-close timer launch_with_timer() { local app="$1" local real_binary="$2" shift 2 + # Check if auto-close is suspended for today + if is_autoclose_suspended "$app"; then + log_message "LAUNCHED: $app (auto-close suspended for today)" + exec "$real_binary" "$@" + fi + # Use per-app timeout if set, otherwise fall back to global default local timeout_minutes="${APP_TIMEOUT_MINUTES[$app]:-$AUTO_CLOSE_TIMEOUT_MINUTES}" local warning_seconds=$(((timeout_minutes - AUTO_CLOSE_WARNING_MINUTES) * 60))