Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **Lock message end time and 24:00 ranges:** The configure lock error printed a blank end time (`Lock ends: today`) because it formatted `HH:MM` values, which `parse_config` and the lock-hour reader return, as bare hours. `calculate_restriction_end_time` and `show_config_locked_error` now share `format_endpoint_12h`, so the message reads `Lock ends: 5:30 AM today`. A range that ends at 24 or 24:00 (for example `16-24`) now reads as ending at 12:00 AM on the next day. It used to read 12:00 PM, and `build_weekly_restricted_intervals` dropped it, so the popup's next-unrestricted time treated that evening as free. `range_endpoint_to_day_minutes` takes an `end` role that accepts 24, as the 16-hour cap code already did. A range that ends at the week boundary (Saturday 24:00) now continues into Sunday in that search. `status.sh` and the configure range summary also print a 24:00 end as 12:00 AM. No restriction, lock, cap, or popup-lifetime check changed: the runtime restricted-time test already handled 24:00.
- **Wayland resolution detection:** `get_display_resolution` tests `A || B && C`, which Bash reads as `(A || B) && C`, so `WAYLAND_DISPLAY` alone never selected Wayland detection. It now does, with or without `XDG_SESSION_TYPE`.
- **Pause notice icon:** The Linux "Pause Activated" dialog passes the same yad, zenity, and kdialog icon flags as the warning. A warning that already ran in that process supplies the cached help answer, so the notice does not probe again. The notice watchdog, buttons, and per-day cap are unchanged.
- **Icon help probe:** The help check runs the command in its own process group and reads the result from a temporary file after that group is stopped. GNU `timeout` and `gtimeout` are not used: they return when the direct child exits and leave a descendant holding the pipe. A descendant that leaves the process group is not signalled, and it still cannot hold the popup, because the popup reads the file. The check sends SIGTERM after one second and SIGKILL one second later, or SIGKILL immediately if the leader exits sooner. The help file is capped at 2 MiB so a writer that leaves the process group cannot fill the disk. Popup buttons, the watchdog, and the per-day cap are unchanged.
- **Greptile review fixes:** Pre-spawn gamescope root-size queries now have a roughly two-second deadline, kill and reap stalled probes, and use fallback dimensions on failure. The test runner preserves its selected Bash interpreter for child tests when PATH points to an older Bash.
Expand Down
4 changes: 0 additions & 4 deletions dev-docs/TO_DO.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ Doc convention: **`docs/`** = end-users; **`dev-docs/`** = developers and agents
- Plan: [plans/plan-safety-scan-fixes-2026-05-30.md](plans/plan-safety-scan-fixes-2026-05-30.md) · Analysis: [safety-linux-macos-analysis.md](safety-linux-macos-analysis.md) §5.1
- [ ] **Additional hours on unrestricted days** — Lock/uninstall hours should not apply when a day has no restrictions (opt-in override) → [plan](plans/plan-additional-hours-no-restrictions.md)
- [ ] **Popup frequency early tolerance** — Allow last-popup-time gate to fire up to `min(5% of POPUP_DISPLAY_FREQUENCY, 5 min)` early so 10-min settings do not slip to ~15 min on the 5-min timer grid; clamp early so earliest gap stays above popup on-screen time (`+60s` and `≤90%` cushions). **Plan needs human review — do not implement yet.** → [plan](plans/plan-popup-frequency-early-tolerance-2026-10-19.md)
- [ ] **Three bugs found while writing tests (2026-10-28)** — none is a safety invariant. Each needs its own fix and a test that asserts the corrected behavior.
- `calculate_restriction_end_time` (`lib/time-calculations.sh`) returns a blank end time for `HH:MM-HH:MM` ranges, which is what `parse_config` returns. `format_hour_12h` takes a bare hour, so `05:00` prints `[: 05:00: integer expected` and the result is `|Monday|false`. The overnight tail from the previous day fails the same way. `configure-ui-errors.sh` shows this result in the lock message.
- `build_weekly_restricted_intervals` (`lib/time-calculations.sh`) drops any range that ends at 24, such as `TUESDAY=16-24`, because `range_endpoint_to_day_minutes` accepts hours 0–23 only. `get_next_unrestricted_time` then treats that evening as unrestricted.
- `get_display_resolution` (`lib/resolution-detection.sh`) writes `[ -n "$WAYLAND_DISPLAY" ] || [ -n "$XDG_SESSION_TYPE" ] && [ "$XDG_SESSION_TYPE" = wayland ]`. Bash reads that as `(A || B) && C`, so `WAYLAND_DISPLAY` alone never selects Wayland detection.
- [ ] **#29** — kdialog window size via `--textbox` + `--geometry` → [enhancement-29](enhancements/enhancement-29-kdialog-window-size-control.md)
- [ ] **#10** — Audio alerts → [enhancement-10](enhancements/enhancement-10-audio-alerts.md)
- [x] **Configurable pause cooldown and duration** — Pause disabled, or cooldown every N hours (N = 6, 8, 12, 24; default 24); pause length 1/2/3/5/10/15 min → [plan](completed-plans/plan-configurable-pause-interval.md) (scope: [enhancement-21 pause](enhancements/enhancement-21/enhancement-21-pause-scope-clarification.md))
Expand Down
1 change: 1 addition & 0 deletions dev-docs/testing-assessments/test-tiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Fast, headless, no live installed config. Default timeout 300s per script.
| `test-popup-size-config.sh` | Popup size getters, fixed and display-based dimensions, 95% clamp |
| `test-config-safety.sh` | Default hours, runtime cap inputs, runtime cap gate, wizard default fill |
| `test-time-calculations.sh` | Range durations, weekly intervals, next unrestricted time, restriction end time |
| `test-config-locked-message.sh` | Text of the configure lock error: active range, end time, end day |
| `test-scheduler-platform.sh` | systemd and launchd helpers with a stubbed `systemctl` |
| `test-resolution-detection-stubbed.sh` | xrandr, Wayland and gamescope resolution detection with stub tools |
| `test-configure-dialogs-darwin-ui.py` | macOS configure dialogs with fake tkinter widgets (run by the Python coverage gate, not `run-tests.sh`) |
Expand Down
29 changes: 29 additions & 0 deletions lib/configure-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# - has_gui() - Check if GUI is available
# - minutes_to_oncalendar() - Convert minutes to systemd OnCalendar format
# - format_hour_12h() - Format hour to 12-hour format with AM/PM
# - format_endpoint_12h() - Format a range endpoint (H, HH:MM, 24:00) to 12-hour format
# - get_threshold_warn_description() - Get human-readable warning threshold description
# - get_threshold_block_description() - Get human-readable block threshold description
# - day_num_to_name_upper() - Convert day number to uppercase day name (for config file)
Expand Down Expand Up @@ -355,6 +356,34 @@
fi
}

# Format a range endpoint as "H:MM AM/PM".
# Accepts a bare hour ("5", "05") or "H:MM" / "HH:MM", the forms parse_config and
# the lock-hour readers return. A bare hour prints ":00", so "5" matches
# format_hour_12h. An end of 24 or 24:00 is midnight and prints "12:00 AM".
# Prints nothing and returns 1 for anything else.
format_endpoint_12h() {
local part="${1//[[:space:]]/}"
local hour minute display ampm
if [[ "${part}" =~ ^([0-9]{1,2})(:([0-9]{2}))?$ ]]; then
hour=$((10#${BASH_REMATCH[1]}))
minute=$((10#${BASH_REMATCH[3]:-0}))
else
return 1
fi
if [ "${minute}" -gt 59 ] || [ "${hour}" -gt 24 ] || { [ "${hour}" -eq 24 ] && [ "${minute}" -ne 0 ]; }; then

Check failure on line 373 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-O&open=AaGDfqmzpnR4UwpLpM-O&pullRequest=4

Check failure on line 373 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-N&open=AaGDfqmzpnR4UwpLpM-N&pullRequest=4

Check failure on line 373 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-M&open=AaGDfqmzpnR4UwpLpM-M&pullRequest=4

Check failure on line 373 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-P&open=AaGDfqmzpnR4UwpLpM-P&pullRequest=4
return 1
fi
ampm="AM"
if [ "${hour}" -ge 12 ] && [ "${hour}" -lt 24 ]; then

Check failure on line 377 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-R&open=AaGDfqmzpnR4UwpLpM-R&pullRequest=4

Check failure on line 377 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-Q&open=AaGDfqmzpnR4UwpLpM-Q&pullRequest=4
ampm="PM"
fi
display=$((hour % 12))
if [ "${display}" -eq 0 ]; then

Check failure on line 381 in lib/configure-core.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqmzpnR4UwpLpM-S&open=AaGDfqmzpnR4UwpLpM-S&pullRequest=4
display=12
fi
printf '%d:%02d %s\n' "${display}" "${minute}" "${ampm}"
}

# Get human-readable description of warning threshold
# Returns: "X hours/day" format
get_threshold_warn_description() {
Expand Down
6 changes: 3 additions & 3 deletions lib/configure-ui-errors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _configure_ui_errors_ensure_deps() {
# shellcheck disable=SC1091
[ -f "${_dir}/time-parsing.sh" ] && source "${_dir}/time-parsing.sh"
fi
if ! type format_hour_12h >/dev/null 2>&1 || ! type format_ranges_human >/dev/null 2>&1; then
if ! type format_hour_12h >/dev/null 2>&1 || ! type format_endpoint_12h >/dev/null 2>&1 || ! type format_ranges_human >/dev/null 2>&1; then
local _dir
_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
Expand Down Expand Up @@ -439,7 +439,7 @@ show_config_locked_error() {
end_part=$(echo "${end_part}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if range_overnight_tail_active_for_hour "${current_hour}" "${start_part}" "${end_part}"; then
local end_12h
end_12h=$(format_hour_12h "${end_part}")
end_12h=$(format_endpoint_12h "${end_part}") || continue
lock_end="${end_12h}|${day_name}|true"
break
fi
Expand Down Expand Up @@ -526,7 +526,7 @@ show_config_locked_error() {
end_part=$(echo "${end_part}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if range_overnight_tail_active_for_hour "${current_hour}" "${start_part}" "${end_part}"; then
local end_12h
end_12h=$(format_hour_12h "${end_part}")
end_12h=$(format_endpoint_12h "${end_part}") || continue
end_info="${end_12h}|${day_name}|true"
break
fi
Expand Down
2 changes: 1 addition & 1 deletion lib/resolution-detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ get_display_resolution() {
if [ -n "${DISPLAY}" ]; then
# X11 session
display_env="x11"
elif [ -n "${WAYLAND_DISPLAY}" ] || [ -n "${XDG_SESSION_TYPE}" ] && [ "${XDG_SESSION_TYPE}" = "wayland" ]; then
elif [ -n "${WAYLAND_DISPLAY}" ] || [ "${XDG_SESSION_TYPE}" = "wayland" ]; then
# Wayland session
display_env="wayland"
elif pgrep -x gamescope >/dev/null 2>&1; then
Expand Down
9 changes: 3 additions & 6 deletions lib/status-config-display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
return 0
fi

local display_hour="${hour}"
local ampm="AM"

if [ "${hour}" -ge 12 ]; then
# 24:00 is midnight at the end of the day, so it stays AM.
if [ "${hour}" -ge 12 ] && [ "${hour}" -lt 24 ]; then

Check failure on line 29 in lib/status-config-display.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqpCpnR4UwpLpM-U&open=AaGDfqpCpnR4UwpLpM-U&pullRequest=4

Check failure on line 29 in lib/status-config-display.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=kgrizz-git_TimerWarning&issues=AaGDfqpCpnR4UwpLpM-T&open=AaGDfqpCpnR4UwpLpM-T&pullRequest=4
ampm="PM"
if [ "${hour}" -gt 12 ]; then
display_hour=$((hour - 12))
fi
fi

local display_hour=$((10#${hour} % 12))
if [ "${display_hour}" -eq 0 ]; then
display_hour=12
fi
Expand Down
Loading
Loading