aboutsummaryrefslogtreecommitdiff
path: root/timer.1
blob: 57f84bbba9545ce3153c39c66e97d22fde96c06d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
.TH TIMER 1 "ttym 2.0"
.SH NAME
timer \- terminal countdown and stopwatch
.SH SYNOPSIS
.B timer
.RB [ \-qs ]
.RB [ \-c
.IR text ]
.RB [ \-\-no\-persist ]
.RB [ \-\-flash
.BR on | off ]
.RB [ \-\-bar
.IR style ]
.RB [ \-\- ]
.RI [ duration ]
.RI [ message
.IR ... ]
.PP
.B timer \-r
.RB [ \-n
.IR N ]
.RB [ \-\-raw ]
.PP
.B timer \-\-stats
.RB [ today | week | month | all ]
.SH DESCRIPTION
.B timer
is a small terminal countdown timer and stopwatch inspired by suckless philosophy.
A single argument is parsed as a duration and the program counts down.
With no duration argument it runs as a stopwatch.
The progress bar, current elapsed time and time remaining
are redrawn on the same line ten times per second.
.PP
The binary is intentionally small and modular.
Beyond the base build (countdown, stopwatch, ASCII progress bar,
pause/resume, one\-shot terminal bell on completion) every feature is
an optional patch under
.IR patches/ .
Each section below describing a non\-base feature is annotated with
.RI [patch: name ];
those options and behaviours are only present if the corresponding
patch has been applied at build time.
.B timer \-h
always reflects the actual build.
.SH OPTIONS
.SS Base
.TP
.B \-q
Suppress the one\-shot completion bell.
Persistent alert loops, if enabled by a patch, still ring the bell.
.TP
.B \-s
Silent. No bell, no notification, no alert loop.
Equivalent to combining every silencing flag.
.TP
.B \-h
Print usage and exit. Reflects the actual build.
.TP
.B \-\-
End of options. Subsequent arguments are treated as positional even if
they begin with
.BR \- .
.SS Optional, added by patches
.TP
.BR \-c \ \fItext\fR
.RI [patch: logging,
.RI hooks]
Comment associated with this session. With the
.B logging
patch, it is written as the third TSV field and any
.BI + tag
tokens within it are picked up by
.BR "timer \-\-stats" .
With the
.B hooks
patch, it is passed as the fourth argument to each hook script.
.TP
.B \-\-no\-persist
.RI [patch: persist\-alert]
Skip the alert\-until\-keypress loop.
.B timer
emits one bell and one notification, then exits.
.TP
.BR \-\-flash \ \fBon\fR | \fBoff\fR
.RI [patch: flash]
Toggle the reverse\-video terminal flash that runs during the
persistent alert loop. Accepts
.BR on / off / true / false / 1 / 0 / yes / no .
Default is build\-dependent.
.TP
.BR \-\-bar \ \fIstyle\fR
.RI [patch: bar\-styles]
Progress bar style. One of
.BR unicode ,
.BR ascii ,
.BR hash ,
.BR dots ,
.BR line ,
.BR block ,
.BR arrow ,
.BR minimal .
With no patch applied the bar uses the compile\-time
.B BAR_FILL
and
.B BAR_EMPTY
glyphs from
.IR config.h .
.SH SUBCOMMANDS
.SS timer \-r [\-n N] [\-\-raw]
.RI [patch: logging]
Read the session log.
.B \-n N
limits output to the last
.I N
entries.
.B \-\-raw
prints the underlying TSV instead of the formatted table, suitable for
piping through
.BR awk (1),
.BR grep (1)
or
.BR sort (1).
.SS timer \-\-stats [\fIperiod\fR]
.RI [patch: logging]
Print aggregate statistics. Period is one of
.BR today
(default),
.BR week ,
.BR month ,
.BR all .
Entries are summed in total and broken down by
.BI + tag
tokens extracted from comments. Untagged sessions are reported as
.BR (untagged) .
.SH DURATION FORMAT
A duration is either a colon notation or a unit notation. Examples:
.PP
.RS
.nf
25m         twenty\-five minutes
90s         ninety seconds
2h          two hours
1h30m       one and a half hours
01:30:00    one and a half hours
25:00       twenty\-five minutes
.fi
.RE
.PP
Colon notation expects
.IR H:M:S
or
.IR M:S .
Unit notation is a concatenation of one or more
.IR Nh ,
.IR Nm ,
.IR Ns
groups in any order.
.SH MESSAGE
.RI [patch: notify]
Any positional arguments after
.I duration
are joined into the message used for the one\-shot completion
notification. The message is expanded into the
.B notify_cmd
template via the
.B {msg}
placeholder.
.SH KEYS
While the timer is running:
.TP
.B space
Pause or resume the countdown or stopwatch.
.TP
.B q
Quit immediately. Logs the partial session if logging is enabled.
.TP
.B Ctrl+C
Same as
.BR q .
.SH ALERT LOOP
.RI [patch: persist\-alert]
When a countdown reaches zero, instead of emitting one bell and
exiting, the program rings the bell every \(ti1.5 s and polls for a
keypress. Any key acknowledges and exits.
.PP
The loop runs only when
.B timer
is in the foreground.
Background jobs
.RB ( timer
.IR ... \ &)
get one bell and exit normally, leaving the shell quiet.
.PP
If the
.B flash
patch is also applied, each beat of the loop briefly inverts the
terminal colours (reverse\-video). The flash can be suppressed without
disabling the loop via
.BR "\-\-flash off" .
.SH HOOKS
.RI [patch: hooks]
On state transitions
.B timer
invokes optional executables under
.IR ~/.config/ttym/hooks/ :
.TP
.B on_start
Called when a session begins.
.TP
.B on_done
Called when a countdown completes normally.
.TP
.B on_quit
Called when a session is interrupted with
.BR q
or
.BR Ctrl+C ,
or when a stopwatch is stopped.
.PP
Each hook is executed synchronously with three arguments:
.IR mode ,
.IR duration_seconds ,
.IR comment .
The first is
.BR countdown
or
.BR stopwatch ;
the others come from the running session. Hooks must be marked
executable. Standard streams are redirected to
.IR /dev/null .
.SH FILES
.TP
.I ~/.config/ttym/config
.RI [patch: config\-file]
Runtime configuration. Auto\-generated on first run with all keys
commented out.
.TP
.I ~/.config/ttym/ttym.log
.RI [patch: logging]
Session log. TSV with three fields per line:
.RS
.PP
.RS
.nf
YYYY\-MM\-DD HH:MM:SS<TAB>SECONDS<TAB>COMMENT
.fi
.RE
.PP
Designed to be processed with
.BR awk (1)
and
.BR grep (1)
rather than re\-rendered by the binary.
.RE
.TP
.I ~/.config/ttym/hooks/
.RI [patch: hooks]
Directory containing the
.BR on_start ,
.BR on_done ,
.B on_quit
executables described in
.BR HOOKS .
.SH EXAMPLES
A twenty\-five minute work session, tagged for later stats:
.PP
.RS
.nf
timer \-c "+work coding" 25m
.fi
.RE
.PP
A countdown that pops a notification with custom text:
.PP
.RS
.nf
timer 10m Lunch
.fi
.RE
.PP
Total hours logged this week:
.PP
.RS
.nf
timer \-r \-\-raw | awk \-F'\\t' '{s+=$2} END {printf "%dh\\n", s/3600}'
.fi
.RE
.PP
Count
.BR +work
sessions ever:
.PP
.RS
.nf
timer \-r \-\-raw | grep '+work' | wc \-l
.fi
.RE
.PP
Stopwatch with no notifications:
.PP
.RS
.nf
timer \-s
.fi
.RE
.SH DESIGN
The binary does one thing: time intervals and, optionally, log them.
Reports
.RB ( "timer \-r" ,
.BR "timer \-\-stats" )
are read\-only views over the same TSV log. For any other view, pipe
.B "timer \-r \-\-raw"
through
.BR awk (1),
.BR grep (1)
or
.BR sort (1).
No daemon, no IPC, no plugin system, no embedded TUI. Hooks are
git\-style: executables you write yourself.
.PP
Compile\-time options live in
.IR config.h ;
runtime overrides (when the
.B config\-file
patch is applied) live in
.IR ~/.config/ttym/config .
.SH AUTHORS
.B timer
is maintained by \(/Lukasz Kasprzak.
Distributed under the MIT license; see
.B LICENSE
in the source tree.
.SH SEE ALSO
.BR awk (1),
.BR grep (1),
.BR notify\-send (1),
.BR paplay (1),
.BR patch (1)