1 ----------------------------------------------------------------------------
2 -- @author Julien Danjou <julien@danjou.info>
3 -- @copyright 2008 Julien Danjou
4 -- @release @AWESOME_VERSION@
5 ----------------------------------------------------------------------------
10 local http
= require("socket.http")
11 local ltn12
= require("ltn12")
13 local setmetatable
= setmetatable
14 local util
= require("awful.util")
15 local hooks
= require("awful.hooks")
23 --- Root window image display library
28 -- Update a telak wibox.
29 -- @param w The wibox to update.
30 local function update(w
)
31 local tmp
= os
.tmpname()
32 http
.request
{url
= data
[w
].image
, sink
= ltn12
.sink
.file(io
.open(tmp
, "w"))}
33 local img
= capi
.image(tmp
)
35 w
:geometry({ width
= img
.width
, height
= img
.height
})
43 --- Create a new telak wibox. This will be automagically update to show a
44 -- local or remote image.
45 -- @param args A table with arguments: image is the local or remote image.
46 -- Timer can be specified to set the time in seconds between two update.
47 -- Default is 300 seconds.
48 -- @return The wibox. You need to attach it to a screen and to set its
49 -- coordinates as you want.
50 local function new(_
, args
)
51 if not args
or not args
.image
then return end
54 local w
= capi
.wibox({ position
= "floating" })
55 data
[w
] = { image
= args
.image
}
56 local wimg
= capi
.widget({ type = "imagebox" })
59 data
[w
].cb
= function () update(w
) end
60 hooks
.timer
.register(args
.timer
or 3, data
[w
].cb
)
67 --- Delete a telak wibox.
68 -- @param w The wibox.
71 hooks
.timer
.unregister(data
[w
].cb
)
76 setmetatable(_M
, { __call
= new
})
78 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80