| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous examples largely duplicated features of the patched build.
on_done sent a desktop notification and played a sound, both of which
the notify patch already does, so a user who copied it got two of each.
on_quit recorded abandoned sessions, but the logging patch calls
write_log() unconditionally at the end of every run: abandoned sessions
were already in the log behind timer -r.
The new set does two things nothing else can:
- Intent versus outcome. The log stores elapsed seconds only, so a
finished 25m and an abandoned 30m that ran 25m are indistinguishable
in it. The duration actually requested is visible to on_start and
nowhere else, so the examples write START/DONE/QUIT records to
$XDG_STATE_HOME/ttym/sessions.tsv.
- Focus mode. During a countdown, pause dunst notifications and any
playerctl/mpc playback; restore on done or quit. Countdown only, so
a stopwatch cannot silence notifications indefinitely.
A timewarrior bridge is included but commented out.
Two behaviours documented in the file comments, both read off the code
rather than assumed: notify_and_sound() runs before the on_done hook, so
with dunst paused the completion popup is queued and appears when the
hook unpauses -- delayed, not lost; and nothing restores dunst if the
process is killed with -9.
Every external command is guarded with command -v, so the examples
degrade to the session record alone on a machine without those tools.
Each hook works standalone -- the man page and README now say so
explicitly, since installing only on_quit is a normal setup. All three
pass sh -n and shellcheck, and were tested across all three paths:
completed countdown, abandoned countdown, stopped stopwatch, with
dunstctl is-paused confirmed false afterwards.
Claude-Session: https://claude.ai/code/session_01APLBs8RB1FcUaC4viVkzbP
|
|
|
Add hooks/on_start, hooks/on_done and hooks/on_quit. They are named
after the hooks themselves so copying one into ~/.config/ttym/hooks/ is
the entire installation step, and each carries its argument contract in
a header comment.
on_start sets the terminal window title to what is running
on_done desktop notification plus a sound, both backgrounded, with
the first available of paplay/aplay/mpv/ffplay
on_quit records abandoned sessions to a TSV under XDG_STATE_HOME and
restores the terminal title
make install places them in PREFIX/share/doc/ttym/hooks; make uninstall
removes them and both directories; make dist ships hooks/ with the
executable bits intact.
The man page's HOOKS section now documents what the code actually does
rather than what could be assumed from the call sites:
- $2 differs per hook: requested duration on on_start, full duration
on on_done, and time actually elapsed -- excluding time spent paused
-- on on_quit. An abandoned 25m countdown reports what really ran.
- $3 is always passed, so it is never unset.
- hooks block: timer forks and waitpid()s, so on_done delays the
completion bell and the alert loop. Background anything slow.
- stdin, stdout and stderr all go to /dev/null, which is why printing
is pointless and cannot corrupt the redrawn progress line.
- execvp(3) means a script needs a #! line.
README gains a Hooks section. All three examples pass sh -n and
shellcheck, and were tested end to end through the documented flow:
make install to a staging prefix, copy into a config dir, run.
Claude-Session: https://claude.ai/code/session_01APLBs8RB1FcUaC4viVkzbP
|