Lua primitives: on_idle()
NOTE: Lumail-legacy has been superseded by Lumail 2.x, which has a wholly unified Lua API.
If you define the function on_idle it will be called approximately once a second when the the client is idle.
For example:
function on_idle() msg( "The client is idle " .. os.date() ); end
By default on_idle will be invoked too regularly to sync your email from a remote source with imapsync, getmail, etc.
But using this function you can schedule regular tasks. For example the following will execute imapsync approximately once every five minutes:
do -- last sync time. local ls = os.time() function on_idle() -- get current time ct = os.time() if ( ( ct - ls ) >= ( 60 * 5 ) ) then ls = ct os.execute( "imapsync" ); end -- now handle the normal on_idle stuff.. end end
Availability
This function has been available since version 0.07.
See Also
See also on_complete, on_exit, on_key, on_read_message, sleep.