From: martin f. krafft Date: Mon, 12 Feb 2018 22:46:40 +0000 (+1300) Subject: Globetrotter clock display X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/1fb948b72b60999c61027ddb76d294c954a95f14?ds=sidebyside;hp=--cc;pf=etc Globetrotter clock display --- 1fb948b72b60999c61027ddb76d294c954a95f14 diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 99b72e9..861013b 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -15,6 +15,7 @@ local lain = require("lain") local dkjson = require("lain.util").dkjson local math = require("math") local freedesktop = require("freedesktop") +local luatz = require("luatz") -- }}} -- {{{ Error handling @@ -200,7 +201,24 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ local spacer = wibox.widget.textbox() spacer:set_text(' | ') -- Create a textclock widget -mytextclock = wibox.widget.textclock("%a %d %b %H:%M:%S", 1) +clocks = { wibox.widget.textclock("%a %d %b %H:%M:%S", 1) } + +ZONES = { + ["NZ"] = "Pacific/Auckland", + ["DE"] = "Europe/Berlin" +} + +now = luatz.time_in(nil) +for c, tz in sorted_pairs(ZONES) do + t = luatz.time_in(tz) + print (c) + print (os.difftime(t, now)) + if math.abs(os.difftime(t, now)) > 10 then + local widget = wibox.widget.textclock(c .. ": %H:%M (%a)", 60, tz) + table.insert(clocks, spacer) + table.insert(clocks, widget) + end +end -- Create a wibox for each screen and add it mywibox = {} @@ -336,17 +354,21 @@ awful.screen.connect_for_each_screen(function(s) mypromptbox[s], }, mytasklist[s], -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - mykeyboardlayout, - wibox.widget.systray(), - btc_widget, - spacer, - lain_bat.widget, - spacer, - mytextclock, - mylayoutbox[s], - }, + awful.util.table.join( -- Right widgets + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + wibox.widget.systray(), + btc_widget, + spacer, + lain_bat.widget, + spacer, + }, + clocks, + { + mylayoutbox[s], + } + ), } end) -- }}}