You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
43 lines
1.6 KiB
-- wibox.widget.textclock but with awmtk2 templates.
|
|
local awmtk2 = require("awmtk2")
|
|
local wibox = require("wibox")
|
|
local gears = require("gears")
|
|
local awful = require("awful")
|
|
local beautiful = require("beautiful")
|
|
local glib = require("lgi").GLib
|
|
local DateTime = glib.DateTime
|
|
local TimeZone = glib.TimeZone
|
|
|
|
return function(args)
|
|
local style = awmtk2.create_style("clock",awmtk2.default,args.style)
|
|
local templates = awmtk2.create_template_lib("clock",awmtk2.templates,args.templates)
|
|
local t = awmtk2.build_templates(templates,style)
|
|
-- Don't mind me just stealing default library code
|
|
local format = args.format or "%a %b %d, %H:%M"
|
|
local refresh = args.refresh or 60
|
|
local tzid = args.tzid
|
|
local timezone = (tzid and TimeZone.new(tzid)) or TimeZone.new_local()
|
|
|
|
-- Seriously, was it so hard to add a font parameter for textclock?
|
|
-- Do you actually expect of nobody to change the font to something like
|
|
-- idk, 7-segment display? Goddamnit awesome. I trusted you.
|
|
local widget = wibox.widget(t.container(t.textbox({
|
|
id = "clocktext"
|
|
})))
|
|
local textbox = widget:get_children_by_id("clocktext")[1]
|
|
widget.clocktimer = gears.timer {
|
|
timeout = refresh,
|
|
call_now = true,
|
|
autostart = true,
|
|
callback = function()
|
|
local str = DateTime.new_now(timezone):format(format)
|
|
if str == nil then
|
|
require("gears.debug").print_warning("clock: "
|
|
.. "g_date_time_format() failed for format "
|
|
.. "'" .. format .. "'")
|
|
end
|
|
textbox:set_markup(str)
|
|
end
|
|
}
|
|
return widget
|
|
end
|