From 5af7fe23406dfdfab986972d0ee6e6b21c2d58fb Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 19 Dec 2020 09:23:40 +0100 Subject: [PATCH] add config option for instance name This is needed if you have multiple instances of this package running side-by-side --- node.json | 7 +++++++ node.lua | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/node.json b/node.json index 95e7de8..b8cf116 100644 --- a/node.json +++ b/node.json @@ -58,6 +58,13 @@ [30, "30px"], [40, "40px"] ] + }, { + "title": "instance name", + "ui_width": 12, + "name": "instance_name", + "type": "string", + "default": "icinga2", + "hint": "Something to describe the displayed output, will be shown next to the update datum" }, { "title": "Connection to icinga2", "type": "section" diff --git a/node.lua b/node.lua index 5829018..eda49c9 100644 --- a/node.lua +++ b/node.lua @@ -45,12 +45,18 @@ function node.render() end end - local time_width = CONFIG.font:width(services.prettytime, CONFIG.output_size) + if CONFIG.instance_name ~= "" then + titlebar = CONFIG.instance_name .. " - " .. services.prettytime + else + titlebar = servics.prettytime + end + + local title_width = CONFIG.font:width(titlebar, CONFIG.output_size) local host_width = 0 transform() CONFIG.background_color.clear() - CONFIG.font:write(real_width/2-time_width/2, CONFIG.output_size*0.5, services.prettytime, CONFIG.output_size, 1,1,1,1) + CONFIG.font:write(real_width/2-title_width/2, CONFIG.output_size*0.5, titlebar, CONFIG.output_size, 1,1,1,1) for idx, service in ipairs(services.services) do host_width = math.max(host_width, CONFIG.font:width(service.host, CONFIG.header_size))