i3bar: hide gaming blocks, gaming off
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run

Gaming is unlimited from 2026-11-16 (earned_time 0.22.0). Drop [gaming_budget] and [leisure_shadow] from the i3blocks config. Both scripts also print nothing when the daily-limits cache has gaming_enforced false, so a bar config that still lists them stays blank. Shutdown, tutor and focus blocks are untouched. Pruned the oldest evidence file for the 60-file cap.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWViGJJaqBKGr1Hbppr
This commit is contained in:
Krzysztof Rudnicki 2026-11-16 16:11:08 +01:00
parent 40becf498d
commit 79c8a7ad09
8 changed files with 115 additions and 65 deletions

View File

@ -0,0 +1,11 @@
{
"title": "i3blocks: no gaming or shadow block once gaming is not limited",
"objective": "Remove [gaming_budget] and [leisure_shadow] from the i3blocks config and make both scripts print nothing when daily-limits' cache has gaming_enforced false; a missing or true key keeps current behaviour; both always exit 0 and stay shellcheck clean.",
"acceptance_criteria": [
"gaming_enforced false: gaming_budget and leisure_shadow print 0 lines and exit 0, even for stale or no-data caches",
"gaming_enforced missing or true: output identical to before",
"the config wires neither block; shutdown_countdown, tutor and focus_project sections are unchanged"
],
"out_of_scope": ["daily-limits itself (own repo)", "enforcer behaviour"],
"verifier": "linux_configuration/tests/test_i3blocks_gaming_budget.sh, test_i3blocks_leisure_shadow.sh, test_i3blocks_efficiency.sh, shellcheck, pre-commit"
}

View File

@ -1,43 +0,0 @@
{
"intent": "The endurain_import phone fallback stops re-pulling RunnerUp exports that were already imported, so each run no longer copies the whole phone history back into the WebDAV inbox, and one summary line says what happened.",
"scope": [
"python_pkg/endurain_import/sources.py: PROCESSED_DIRNAME, processed_dir_for(), pull_from_phone skip + summary log",
"python_pkg/endurain_import/__main__.py: uses processed_dir_for() instead of a literal 'processed'",
"python_pkg/endurain_import/tests/test_phone_pull.py: new tests",
"Non-goal: the phone is still read-only; nothing on it is deleted"
],
"changes": [
"pull_from_phone skips a name already in the inbox (pending) or in processed/ (imported) before any adb pull",
"One summary line per run: on phone / pulled / skipped imported / skipped pending / failed; logged at WARNING when any pull failed, INFO otherwise",
"processed_dir_for(inbox) is the single definition shared by the importer and the fallback"
],
"verification": [
{
"command": "python3 -m pytest -q --cov=python_pkg.endurain_import --cov-branch python_pkg/endurain_import",
"result": "pass",
"evidence": "103 passed; endurain_import 100% line+branch (sources.py was 97%, lines 174-175 uncovered, before the new tests)"
},
{
"command": "python3 -m python_pkg.endurain_import with stub adb on PATH, stub Endurain on 127.0.0.1:18999, temp inbox (1 file in processed/, 1 in inbox, 1 new, 1 failing pull)",
"result": "pass",
"evidence": "WARNING phone fallback: 4 on phone, 1 pulled, 1 skipped as already imported, 1 skipped as already in the inbox, 1 failed; adb pull called only for the new and the failing file; second run: 0 pulled, 3 skipped as already imported, 0 uploads"
},
{
"command": "live run on the host (reported by the caller session, 17:56)",
"result": "pass",
"evidence": "27 on phone, 0 pulled, 27 skipped as already imported"
},
{
"command": "pre-commit run --files sources.py __main__.py tests/test_phone_pull.py",
"result": "pass",
"evidence": "all hooks passed"
}
],
"risks": [
"A file deleted from processed/ by hand would be pulled again (then deduped by the ledger), which is the intended recovery path."
],
"rollback": [
"git revert this commit",
"After rollback: the next timer run re-pulls the phone history into the inbox; the ledger still prevents duplicate uploads"
]
}

View File

@ -0,0 +1,31 @@
{
"intent": "Gaming has no budget from 2026-11-16 (earned_time 0.22.0): the i3bar shows no gaming or leisure-shadow block; the shutdown, tutor and focus blocks stay.",
"scope": [
"linux_configuration/i3blocks/config, gaming_budget.sh, leisure_shadow.sh and their two test scripts",
"Non-goal: no accounting, no new keys written; a missing or true gaming_enforced keeps today's output"
],
"changes": [
"config: the [gaming_budget] and [leisure_shadow] sections are removed",
"gaming_budget.sh, leisure_shadow.sh: when the cache's gaming_enforced is exactly false the render is empty text plus the hidden sentinel and the block prints nothing, exit 0, whatever the cache age (covers a bar config that still lists them)",
"tests: hidden cases for both blocks (four caches each, enforced true and absent still render, flip false -> true re-renders) and the config no longer wires either block"
],
"verification": [
{
"command": "bash linux_configuration/tests/test_i3blocks_gaming_budget.sh && bash linux_configuration/tests/test_i3blocks_leisure_shadow.sh && bash linux_configuration/tests/test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "All gaming_budget checks passed. All leisure_shadow checks passed. (both new sections RED before the change)"
},
{
"command": "shellcheck on the two scripts and two tests",
"result": "pass",
"evidence": "no findings"
}
],
"risks": [
"i3blocks does not re-read its config on a signal: the removed sections vanish at the next i3blocks restart; until then the scripts print nothing",
"Depends on daily-limits >= 8219dce writing gaming_enforced"
],
"rollback": [
"git revert the commit; the symlinks in ~/.config/i3blocks pick it up on the next tick"
]
}

View File

@ -50,16 +50,6 @@ command=~/.config/i3blocks/pc_startup_status.sh
interval=30
color=#FFFFFF
[gaming_budget]
command=~/.config/i3blocks/gaming_budget.sh
interval=30
# Shadow week: the would-be leisure budget. Never urgent (no flashing).
[leisure_shadow]
command=~/.config/i3blocks/leisure_shadow.sh
interval=30
[screen_locker]
command=~/.config/i3blocks/screen_locker.sh
interval=30

View File

@ -14,6 +14,11 @@
# Phase 2 (leisure rollout): once the cache's top-level `leisure_active` is
# true, the same block is the leisure budget: 🎮 becomes `🛋 Leisure`, colours
# unchanged. A missing/false/non-boolean key keeps the 🎮 gaming label.
#
# Gaming is not limited from 2026-11-16 (earned_time 0.22.0): once the cache's
# top-level `gaming_enforced` is exactly false there is no budget and the
# block prints nothing (i3bar hides it), whatever the cache's age. A missing
# or true key keeps the block.
# ============================================================================
set -euo pipefail
@ -46,7 +51,9 @@ if [[ ${BLOCK_BUTTON:-0} -eq 1 ]]; then
fi
# One jq pass renders five lines: generated_at, full text, short text, color
# and the label (🎮, or `🛋 Leisure` once live) the stale state reuses.
# and the label (🎮, or `🛋 Leisure` once live) the stale state reuses. With
# gaming not limited, full/short are empty and color is "hidden" (non-empty,
# so $(...) cannot strip the lines).
# Thresholds mirror the enforcer's own warn_at (1h, 30m, 10m). Bonuses still
# not done are listed as " +💪2h +🧩?1h" ("?" = status unknown, still counted);
# a gaming day other than the date is shown as " (10-08)"; used_minutes == null means the enforcer
@ -67,7 +74,9 @@ render_limits() {
| if length > 0 then " " + join(" ") else "" end) as $todo
| (if (.gaming.day // .date) != .date then " (\((.gaming.day // .date)[5:]))" else "" end) as $day
| (.generated_at | if type == "number" then floor else "none" end),
(if $g.used_minutes == null then
(if .gaming_enforced == false then
"", "", "hidden"
elif $g.used_minutes == null then
"\($label) budget \($g.budget_minutes | hm)\($day)\($todo)", "\($icon) \($g.budget_minutes | hm)", $grey
else
([$g.budget_minutes - $g.used_minutes, 0] | max) as $left
@ -114,6 +123,9 @@ fi
exit 0
}
# Hidden (no gaming budget): print nothing, whatever the cache's age.
[[ -n $full_text ]] || exit 0
if [[ -n ${NOW_EPOCH:-} ]]; then
now=$NOW_EPOCH
else

View File

@ -15,7 +15,8 @@
# Phase 2 (leisure rollout): once the cache's top-level `leisure_active` is
# true the shadow week is over and the block prints nothing (i3bar hides it);
# gaming_budget.sh shows the real leisure budget instead. A missing/false key
# keeps the shadow block.
# keeps the shadow block. Likewise once `gaming_enforced` is exactly false
# (2026-11-16: no gaming budget, so no shadow of one).
# ============================================================================
set -euo pipefail
@ -47,7 +48,7 @@ render_shadow() {
| "\($m / 60 | floor)h\($m % 60 | tostring | if length < 2 then "0" + . else . end)";
(.leisure_shadow // {}) as $s
| (.generated_at | if type == "number" then floor else "none" end),
(if .leisure_active == true then
(if .leisure_active == true or .gaming_enforced == false then
"", "", "hidden"
elif $s.used_minutes == null or $s.budget_minutes == null then
"🛋 SHADOW ⏱? no data", "🛋 ⏱?", $orange

View File

@ -203,4 +203,36 @@ assert_eq "notify -u critical daily-limits not installed: $TMP_DIR/absent" "$(ca
'a missing launcher raises a notification'
rm -f "$TMP_DIR/clicks"
printf 'Checking the block hides itself once gaming is not limited...\n'
# set_enforced VALUE -- rewrite the cache's top-level gaming_enforced (2026-11-16).
set_enforced() {
jq -c ".gaming_enforced = $1" "$CACHE" >"$CACHE.new" && mv "$CACHE.new" "$CACHE"
rm -f "$RENDER"
}
for spec in "360 480 $NOW" "480 480 $NOW" "null 480 $NOW" "60 480 $((NOW - 600))"; do
read -r used budget generated <<<"$spec"
write_cache "$used" "$budget" "$generated" "$D" workout:todo:60
set_enforced false
set +e
output=$(run_block)
status=$?
set -e
assert_eq '0' "$status" "unenforced ($spec) exits 0"
assert_eq '' "$output" "unenforced ($spec) prints nothing: the block is hidden"
done
# The key absent (an older cache) or true keeps the block: gaming is limited.
write_cache 360 480 "$NOW" "$D" workout:todo:60
assert_eq '🎮 2h00 left · 6h00/8h00 +💪1h' "$(line 1)" 'no gaming_enforced key still shows the budget'
set_enforced true
assert_eq '🎮 2h00 left · 6h00/8h00 +💪1h' "$(line 1)" 'gaming_enforced true still shows the budget'
# Re-enforcing after hidden shows it again (the render cache is rebuilt, not stuck).
set_enforced false
assert_eq '' "$(run_block)" 'hidden again'
set_enforced true
assert_eq '🎮 2h00 left · 6h00/8h00 +💪1h' "$(line 1)" 'visible again'
printf 'Checking the config no longer wires the gaming or shadow blocks...\n'
! grep -q '^\[gaming_budget\]$' "$REPO_DIR/i3blocks/config" || fail '[gaming_budget] must not be in the config'
! grep -q 'gaming_budget.sh' "$REPO_DIR/i3blocks/config" || fail 'config must not run gaming_budget.sh'
printf 'All gaming_budget checks passed.\n'

View File

@ -163,13 +163,29 @@ for value in false null; do
assert_eq '🛋 SHADOW 3h12 left · 1h48 used' "$(line 1)" "leisure_active $value still shows the shadow"
done
printf 'Checking the config wires the block next to gaming_budget...\n'
CONFIG="$REPO_DIR/i3blocks/config"
grep -A3 '^\[leisure_shadow\]$' "$CONFIG" | grep -q '^command=~/.config/i3blocks/leisure_shadow.sh$' ||
fail '[leisure_shadow] should run leisure_shadow.sh'
next_section=$(sed -n '/^\[gaming_budget\]$/,$p' "$CONFIG" | grep -m2 '^\[' | tail -1)
assert_eq '[leisure_shadow]' "$next_section" '[leisure_shadow] sits right after [gaming_budget]'
! grep -A4 '^\[leisure_shadow\]$' "$CONFIG" | grep -q '^urgent' ||
fail '[leisure_shadow] must never be urgent'
printf 'Checking the block hides itself once gaming is not limited...\n'
# set_enforced VALUE -- rewrite the cache's top-level gaming_enforced (2026-11-16).
set_enforced() {
jq -c ".gaming_enforced = $1" "$CACHE" >"$CACHE.new" && mv "$CACHE.new" "$CACHE"
rm -f "$RENDER"
}
for spec in '108 300' '300 300' 'null null' "60 300 $((NOW - 600))"; do
read -r used budget generated <<<"$spec"
write_cache "$used" "$budget" "${generated:-$NOW}"
set_enforced false
set +e
output=$(run_block)
status=$?
set -e
assert_eq '0' "$status" "unenforced ($spec) exits 0"
assert_eq '' "$output" "unenforced ($spec) prints nothing: the block is hidden"
done
write_cache 108 300
set_enforced true
assert_eq '🛋 SHADOW 3h12 left · 1h48 used' "$(line 1)" 'gaming_enforced true still shows the shadow'
printf 'Checking the config no longer wires the shadow block...\n'
! grep -q '^\[leisure_shadow\]$' "$REPO_DIR/i3blocks/config" || fail '[leisure_shadow] must not be in the config'
! grep -q 'leisure_shadow.sh' "$REPO_DIR/i3blocks/config" || fail 'config must not run leisure_shadow.sh'
printf 'All leisure_shadow checks passed.\n'