tui.every
tui.every SEC FN [ID]
Calls FN repeatedly on a timer from the main loop.
Parameters
SEC: interval in seconds; decimals allowed (0.25). Values below0.05are raised to0.05.FN: function, called asFN ID.ID: timer id fortui.every.canceland friends. Default:FN.
Notes
- The first call happens on the next loop iteration, not after
SEC. Usetui.afterfor a delayed start. - Registering an existing
IDagain replaces that timer and resumes it if paused. Pass distinct IDs to run one function on two timers. - Timers are removed on page change. Register them again from the page’s
on_visit. - After a terminal resize every timer runs on the next iteration, so size-dependent output re-fits at once.
FNruns inside the main loop: keep it fork-free (tui.set_text,tui.sys.*). Slow work belongs intui.watch.- Timers registered while a plugin loads are removed when that plugin is disabled.
Example
refresh_stats() {
tui.sys.cpu; tui.sys.mem
tui.set_text stats "CPU ${TUI_SYS_CPU}% MEM ${TUI_SYS_MEM_PCT}%"
}
tui.every 2 refresh_stats
See also: tui.after, tui.tick.add, tui.watch
