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")
12 local setmetatable
= setmetatable
13 local util
= require("awful.util")
22 --- Root window image display library
25 local data
= setmetatable({}, { __mode
= 'k' })
27 -- Update a telak wibox.
28 -- @param w The wibox to update.
29 local function update(w
)
30 local tmp
= os
.tmpname()
31 http
.request
{url
= data
[w
].image
, sink
= ltn12
.sink
.file(io
.open(tmp
, "w"))}
32 local img
= capi
.image(tmp
)
34 w
:geometry({ width
= img
.width
, height
= img
.height
})
42 --- Create a new telak wibox. This will be automagically update to show a
43 -- local or remote image.
44 -- @param args A table with arguments: image is the local or remote image.
45 -- Timer can be specified to set the time in seconds between two update.
46 -- Default is 300 seconds.
47 -- @return The wibox. You need to attach it to a screen and to set its
48 -- coordinates as you want.
49 local function new(_
, args
)
50 if not args
or not args
.image
then return end
53 local w
= capi
.wibox
{}
54 data
[w
] = { image
= args
.image
}
55 local wimg
= capi
.widget({ type = "imagebox" })
58 data
[w
].timer
= capi
.timer
{ timeout
= args
.timer
or 300 }
59 data
[w
].timer
:add_signal("timeout", function update(w
) end)
67 --- Delete a telak wibox.
68 -- @param w The wibox.
76 setmetatable(_M
, { __call
= new
})
78 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80