telak: use timer
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e899ca7696
commit
f554060ffe
|
@ -11,9 +11,9 @@ local http = require("socket.http")
|
|||
local ltn12 = require("ltn12")
|
||||
local setmetatable = setmetatable
|
||||
local util = require("awful.util")
|
||||
local hooks = require("awful.hooks")
|
||||
local capi =
|
||||
{
|
||||
timer = timer,
|
||||
wibox = wibox,
|
||||
widget = widget,
|
||||
image = image
|
||||
|
@ -55,8 +55,9 @@ local function new(_, args)
|
|||
local wimg = capi.widget({ type = "imagebox" })
|
||||
w.widgets = wimg
|
||||
|
||||
data[w].cb = function () update(w) end
|
||||
hooks.timer.register(args.timer or 300, data[w].cb)
|
||||
data[w].timer = capi.timer { timeout = args.timer or 300 }
|
||||
data[w].timer:add_signal("timeout", function update(w) end)
|
||||
data[w].timer:start()
|
||||
|
||||
update(w)
|
||||
|
||||
|
@ -67,7 +68,7 @@ end
|
|||
-- @param w The wibox.
|
||||
function delete(w)
|
||||
if data[w] then
|
||||
hooks.timer.unregister(data[w].cb)
|
||||
data[w].timer:stop()
|
||||
data[w] = nil
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue