Module: cwc.timer

Low-level API to create a timer.

Info:

  • Copyright: 2025
  • License: GPLv3
  • Originally authored by: Dwi Asmoro Bangun
    (Full contributors list available on our github project)

Static module functions

cwc.timer.new (timeout, callback, options) Create a new timer.
cwc.timer.delayed_call (callback) Call the given function at the end of wayland event loop.

Object properties

started boolean Whether the timer is currently running or not.
timeout boolean The timer timeout value in seconds.

Object methods

:start () Start the timer.
:stop () Stop the timer.
:again () Restart the timer.
:destroy () Destroy the timer, invalidate the object and freeing it from memory.


Static module functions

🔗 cwc.timer.new (timeout, callback, options)
Create a new timer.

Parameters:

Name Type(s) Description Default value
timeout number Not applicable
callback function Not applicable
options Optional table Additional settings Undefined
autostart Optional boolean Immediately start the timer countdown true
call_now Optional boolean Immediately call the callback function false
single_shot Optional boolean Run only once then stop false
one_shot Optional boolean Run only once then destroy false
🔗 cwc.timer.delayed_call (callback)
Call the given function at the end of wayland event loop.

Parameters:

Name Type(s) Description
callback function

Object properties

🔗 started boolean
Whether the timer is currently running or not.

Constraints:

Default value : false
Valid values : true or false.
🔗 timeout boolean
The timer timeout value in seconds.

Constraints:

Default value : false
Valid values : true or false.

Object methods

🔗 :start ()
Start the timer.
🔗 :stop ()
Stop the timer.
🔗 :again ()
Restart the timer.

Equivalent to stopping the timer and then starting it again.

🔗 :destroy ()
Destroy the timer, invalidate the object and freeing it from memory.
generated by LDoc 1.5.0 based on AwesomeWM template