awful.widget.textclock: import
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
432f4229be
commit
8de5075412
|
@ -12,6 +12,7 @@ require("awful.widget.prompt")
|
||||||
require("awful.widget.progressbar")
|
require("awful.widget.progressbar")
|
||||||
require("awful.widget.graph")
|
require("awful.widget.graph")
|
||||||
require("awful.widget.layoutbox")
|
require("awful.widget.layoutbox")
|
||||||
|
require("awful.widget.textclock")
|
||||||
require("awful.widget.layout")
|
require("awful.widget.layout")
|
||||||
|
|
||||||
--- Widget module for awful
|
--- Widget module for awful
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
-- @author Julien Danjou <julien@danjou.info>
|
||||||
|
-- @copyright 2009 Julien Danjou
|
||||||
|
-- @release @AWESOME_VERSION@
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local os = os
|
||||||
|
local capi = { widget = widget,
|
||||||
|
timer = timer }
|
||||||
|
|
||||||
|
--- Text clock widget.
|
||||||
|
module("awful.widget.textclock")
|
||||||
|
|
||||||
|
--- Create a textclock widget. It draws the time it is in a textbox.
|
||||||
|
-- @param args Standard arguments for textbox widget.
|
||||||
|
-- @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.
|
||||||
|
function new(args, format, timeout)
|
||||||
|
local args = args or {}
|
||||||
|
local format = format or " %a %b %d, %H:%M "
|
||||||
|
local timeout = timeout or 60
|
||||||
|
args.type = "textbox"
|
||||||
|
local w = capi.widget(args)
|
||||||
|
local timer = capi.timer { timeout = timeout }
|
||||||
|
w.text = os.date(format)
|
||||||
|
timer:add_signal("timeout", function() w.text = os.date(format) end)
|
||||||
|
timer:start()
|
||||||
|
return w
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||||
|
|
||||||
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
Loading…
Reference in New Issue