]> git.madduck.net Git - etc/awesome.git/blob - .config/awesome/clocksarray.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

fix completion for run prompt
[etc/awesome.git] / .config / awesome / clocksarray.lua
1 local gears = require("gears")
2 local wibox = require("wibox")
3 local math = require("math")
4 local luatz = require("luatz")
5 local tblutils = require("tblutils")
6
7 local module = {}
8
9 local function get_textclocks_for_timezones(zones)
10     local now = luatz.time_in(nil)
11     local ret = {}
12     for c, tz in tblutils.sorted_pairs(zones) do
13         local t = luatz.time_in(tz)
14         if math.abs(os.difftime(t, now)) > 10 then
15             local widget = wibox.widget.textclock(c .. ": %H:%M (%a)", 60, tz)
16             ret[#ret+1] = widget
17         end
18     end
19     return ret
20 end
21
22 function module.get_clocksarray(strftime, zones, spacer)
23     local ret = {}
24     local zoneclocks = get_textclocks_for_timezones(zones)
25     for i, c in ipairs(zoneclocks) do
26         ret[#ret+1] = c
27         if spacer then
28             ret[#ret+1] = spacer
29         end
30     end
31     ret[#ret+1] = wibox.widget.textclock(strftime, 1)
32     return ret
33 end
34
35 return module