2009-06-30 12:20:21 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
local os = os
|
2010-10-06 14:30:45 +02:00
|
|
|
local textbox = require("wibox.widget.textbox")
|
2014-12-06 16:44:04 +01:00
|
|
|
local timer = require("gears.timer")
|
2009-06-30 12:20:21 +02:00
|
|
|
|
|
|
|
--- Text clock widget.
|
2012-06-14 01:08:27 +02:00
|
|
|
-- awful.widget.textclock
|
|
|
|
local textclock = { mt = {} }
|
2009-06-30 12:20:21 +02:00
|
|
|
|
|
|
|
--- Create a textclock widget. It draws the time it is in a textbox.
|
|
|
|
-- @param format The time format. Default is " %a %b %d, %H:%M ".
|
|
|
|
-- @param timeout How often update the time. Default is 60.
|
|
|
|
-- @return A textbox widget.
|
2012-06-14 01:08:27 +02:00
|
|
|
function textclock.new(format, timeout)
|
2009-06-30 12:20:21 +02:00
|
|
|
local format = format or " %a %b %d, %H:%M "
|
|
|
|
local timeout = timeout or 60
|
2010-10-06 14:30:45 +02:00
|
|
|
|
|
|
|
local w = textbox()
|
2014-12-06 16:44:04 +01:00
|
|
|
local t = timer { timeout = timeout }
|
|
|
|
t:connect_signal("timeout", function() w:set_markup(os.date(format)) end)
|
|
|
|
t:start()
|
|
|
|
t:emit_signal("timeout")
|
2009-06-30 12:20:21 +02:00
|
|
|
return w
|
|
|
|
end
|
|
|
|
|
2012-06-14 01:08:27 +02:00
|
|
|
function textclock.mt:__call(...)
|
|
|
|
return textclock.new(...)
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(textclock, textclock.mt)
|
2009-06-30 12:20:21 +02:00
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|