mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 13:07:49 +01:00
i3blocks: automation_tutor block -> tutor (ledger ~/.local/share/tutor, click ~/src/tutor/run.sh)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YADHKXzZhhePzQ2rNoXFcK
This commit is contained in:
parent
c4d5631054
commit
a511403e0f
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"title": "i3 bar: automation_tutor block renamed to tutor",
|
||||||
|
"objective": "The bar's tutor block reads ~/.local/share/tutor/ledger.json and a click runs ~/src/tutor/run.sh; the daily-limits renderers show the gear for earned_time 0.9.0's 'tutor' earner.",
|
||||||
|
"acceptance_criteria": [
|
||||||
|
"test_i3blocks_tutor.sh passes (counts, hidden at 4/4, unreadable ledger, click)",
|
||||||
|
"test_i3blocks_gaming_budget.sh passes",
|
||||||
|
"~/.config/i3blocks/tutor.sh prints 'tutor n/4' from the live ledger at the new path"
|
||||||
|
],
|
||||||
|
"out_of_scope": [
|
||||||
|
"What the block counts (rows vs minutes) -- unchanged",
|
||||||
|
"The tutor itself (kuhyx/tutor)"
|
||||||
|
],
|
||||||
|
"verifier": "bash linux_configuration/tests/test_i3blocks_tutor.sh; bash linux_configuration/tests/test_i3blocks_gaming_budget.sh"
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"intent": "The automation tutor is now just Tutor (own repo ~/src/tutor, data ~/.local/share/tutor, earned_time 0.9.0 earner 'tutor'); the i3 bar follows the rename.",
|
||||||
|
"scope": [
|
||||||
|
"linux_configuration/i3blocks/tutor.sh (was automation_tutor.sh), the [tutor] stanza in linux_configuration/i3blocks/config, linux_configuration/tests/test_i3blocks_tutor.sh",
|
||||||
|
"gaming_budget.sh and shutdown_countdown.sh icon maps: earner 'tutor' gets the same gear as 'automation'",
|
||||||
|
"Non-goal: no change to what the block counts (still today's credit rows / 4)"
|
||||||
|
],
|
||||||
|
"changes": [
|
||||||
|
"Ledger default ~/.local/share/tutor/ledger.json (override TUTOR_LEDGER); click runs ~/src/tutor/run.sh (override TUTOR_RUN)",
|
||||||
|
"Block and test renamed; ~/.config/i3blocks/tutor.sh symlink replaces automation_tutor.sh",
|
||||||
|
"tutor: \"⚙\" added beside automation in the two daily-limits renderers"
|
||||||
|
],
|
||||||
|
"verification": [
|
||||||
|
{
|
||||||
|
"command": "bash linux_configuration/tests/test_i3blocks_tutor.sh",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "tutor block: all checks passed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bash linux_configuration/tests/test_i3blocks_gaming_budget.sh",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "All gaming_budget checks passed."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "~/.config/i3blocks/tutor.sh",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "⚙ tutor 0/4 (live ledger at the new path)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"risks": [
|
||||||
|
"The i3blocks config is symlinked, so the [tutor] stanza is live on the next i3blocks reload; until then the old stanza points at a removed symlink"
|
||||||
|
],
|
||||||
|
"rollback": [
|
||||||
|
"git revert the commit and re-link ~/.config/i3blocks/automation_tutor.sh"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -63,8 +63,8 @@ interval=30
|
|||||||
command=~/.config/i3blocks/book_guard.sh
|
command=~/.config/i3blocks/book_guard.sh
|
||||||
interval=30
|
interval=30
|
||||||
|
|
||||||
[automation_tutor]
|
[tutor]
|
||||||
command=~/.config/i3blocks/automation_tutor.sh
|
command=~/.config/i3blocks/tutor.sh
|
||||||
interval=30
|
interval=30
|
||||||
|
|
||||||
[issue_dashboard]
|
[issue_dashboard]
|
||||||
|
|||||||
@ -54,7 +54,7 @@ render_limits() {
|
|||||||
def hm: . as $m
|
def hm: . as $m
|
||||||
| "\($m / 60 | floor)h\($m % 60 | tostring | if length < 2 then "0" + . else . end)";
|
| "\($m / 60 | floor)h\($m % 60 | tostring | if length < 2 then "0" + . else . end)";
|
||||||
def bonus_hm: if . < 60 then "\(.)m" else hm | sub("h00$"; "h") end;
|
def bonus_hm: if . < 60 then "\(.)m" else hm | sub("h00$"; "h") end;
|
||||||
{workout: "💪", leetcode: "🧩", reading: "📖", anki: "🗂", automation: "⚙"} as $icon
|
{workout: "💪", leetcode: "🧩", reading: "📖", anki: "🗂", automation: "⚙", tutor: "⚙"} as $icon
|
||||||
| .gaming as $g
|
| .gaming as $g
|
||||||
| ([.earners[] | select(.status != "done" and .gaming_minutes > 0)
|
| ([.earners[] | select(.status != "done" and .gaming_minutes > 0)
|
||||||
| "+\($icon[.name] // .label)\(if .status == "unknown" then "?" else "" end)\(.gaming_minutes | bonus_hm)"]
|
| "+\($icon[.name] // .label)\(if .status == "unknown" then "?" else "" end)\(.gaming_minutes | bonus_hm)"]
|
||||||
|
|||||||
@ -179,7 +179,7 @@ render_limits() {
|
|||||||
def bonus_hm: . as $m
|
def bonus_hm: . as $m
|
||||||
| if $m < 60 then "\($m)m"
|
| if $m < 60 then "\($m)m"
|
||||||
else "\($m / 60 | floor)h" + ($m % 60 | if . == 0 then "" else "\(.)" | if length < 2 then "0" + . else . end end) end;
|
else "\($m / 60 | floor)h" + ($m % 60 | if . == 0 then "" else "\(.)" | if length < 2 then "0" + . else . end end) end;
|
||||||
{workout: "💪", leetcode: "🧩", reading: "📖", anki: "🗂", automation: "⚙"} as $icon
|
{workout: "💪", leetcode: "🧩", reading: "📖", anki: "🗂", automation: "⚙", tutor: "⚙"} as $icon
|
||||||
| (.earners | map({(.name): .}) | add // {}) as $by
|
| (.earners | map({(.name): .}) | add // {}) as $by
|
||||||
| (.shutdown.applied // .shutdown.resolved) as $time
|
| (.shutdown.applied // .shutdown.resolved) as $time
|
||||||
| (.shutdown.ceiling) as $ceiling
|
| (.shutdown.ceiling) as $ceiling
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Automation tutor status for i3blocks: today's credited 15-minute blocks.
|
# Tutor status for i3blocks: today's credited 15-minute blocks.
|
||||||
#
|
#
|
||||||
# A click runs plc-lab's run.sh, which starts the tutor if it is down and
|
# A click runs ~/src/tutor/run.sh, which starts the tutor if it is down and
|
||||||
# opens it in the browser -- nobody has to remember the port. Hidden once all
|
# opens it in the browser -- nobody has to remember the port. Hidden once all
|
||||||
# four blocks are in: nothing left to earn, nothing to click.
|
# four blocks are in: nothing left to earn, nothing to click.
|
||||||
#
|
#
|
||||||
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
readonly LEDGER="${AUTOMATION_TUTOR_LEDGER:-$HOME/.local/share/automation_tutor/ledger.json}"
|
readonly LEDGER="${TUTOR_LEDGER:-$HOME/.local/share/tutor/ledger.json}"
|
||||||
# i3blocks' PATH has no ~/src: absolute path.
|
# i3blocks' PATH has no ~/src: absolute path.
|
||||||
readonly RUN="${AUTOMATION_TUTOR_RUN:-$HOME/src/plc-lab/run.sh}"
|
readonly RUN="${TUTOR_RUN:-$HOME/src/tutor/run.sh}"
|
||||||
readonly TARGET=4
|
readonly TARGET=4
|
||||||
|
|
||||||
readonly YELLOW='#F1FA8C'
|
readonly YELLOW='#F1FA8C'
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Behaviour tests for the i3blocks automation_tutor block: today's credit
|
# Behaviour tests for the i3blocks tutor block: today's credit
|
||||||
# count, the hidden 4/4 state, the unreadable-ledger warning and the click.
|
# count, the hidden 4/4 state, the unreadable-ledger warning and the click.
|
||||||
# The ledger is a fixture and run.sh is a stub, so nothing reads the real
|
# The ledger is a fixture and run.sh is a stub, so nothing reads the real
|
||||||
# ledger and no tutor or browser is ever started.
|
# ledger and no tutor or browser is ever started.
|
||||||
@ -7,7 +7,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||||
REPO_DIR=$(cd -- "$SCRIPT_DIR/.." && pwd)
|
REPO_DIR=$(cd -- "$SCRIPT_DIR/.." && pwd)
|
||||||
BLOCK="$REPO_DIR/i3blocks/automation_tutor.sh"
|
BLOCK="$REPO_DIR/i3blocks/tutor.sh"
|
||||||
TMP_DIR=$(mktemp -d)
|
TMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@ -30,7 +30,7 @@ assert_eq() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf '{}' | jq -e . >/dev/null 2>&1 ||
|
printf '{}' | jq -e . >/dev/null 2>&1 ||
|
||||||
fail 'a working jq is required for the automation_tutor tests (pacman -S jq)'
|
fail 'a working jq is required for the tutor block tests (pacman -S jq)'
|
||||||
|
|
||||||
BIN_DIR="$TMP_DIR/bin"
|
BIN_DIR="$TMP_DIR/bin"
|
||||||
mkdir -p "$BIN_DIR"
|
mkdir -p "$BIN_DIR"
|
||||||
@ -57,7 +57,7 @@ ledger() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_block() {
|
run_block() {
|
||||||
AUTOMATION_TUTOR_LEDGER="$LEDGER" AUTOMATION_TUTOR_RUN="$BIN_DIR/run.sh" \
|
TUTOR_LEDGER="$LEDGER" TUTOR_RUN="$BIN_DIR/run.sh" \
|
||||||
bash "$BLOCK"
|
bash "$BLOCK"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ line() {
|
|||||||
sed -n "${1}p" <<<"$2"
|
sed -n "${1}p" <<<"$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
printf 'Checking automation_tutor block states...\n'
|
printf 'Checking tutor block states...\n'
|
||||||
|
|
||||||
rm -f "$LEDGER"
|
rm -f "$LEDGER"
|
||||||
out=$(run_block)
|
out=$(run_block)
|
||||||
@ -103,4 +103,4 @@ for _ in 1 2 3 4 5 6 7 8 9 10; do
|
|||||||
done
|
done
|
||||||
assert_eq 'clicked' "$(cat "$TMP_DIR/clicks" 2>/dev/null)" 'click runs run.sh'
|
assert_eq 'clicked' "$(cat "$TMP_DIR/clicks" 2>/dev/null)" 'click runs run.sh'
|
||||||
|
|
||||||
printf 'automation_tutor block: all checks passed\n'
|
printf 'tutor block: all checks passed\n'
|
||||||
Loading…
Reference in New Issue
Block a user