confgen: correctly fetch hostname

This commit is contained in:
LordMZTE 2023-06-09 14:28:26 +02:00
parent da8207936c
commit 450179c801
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 15 additions and 5 deletions

View file

@ -91,7 +91,7 @@ conky.config = {
};
conky.text = [[
${alignc}${color0}${font2}<% opt.system "hostname" %>${font}
${alignc}${color0}${font2}<% opt.read "/etc/hostname" %>${font}
${voffset 6}${alignc}${color0}${font3}${time %b %d, %Y}${font}${color}
${voffset 18}${goto 12}${color5}CPU${goto 50}
${goto 12}$cpu%

View file

@ -23,22 +23,32 @@ end
cg.opt = merge(cg.opt, require "cg_opts")
local local_opts = loadfile(os.getenv "HOME" .. "/.config/mzte_localconf/opts.lua")
if local_opts then
cg.opt = merge(cg.opt, local_opts())
end
-- This function is called in templates to allow adding device-specific configs.
cg.opt.getDeviceConf = function(id)
local path = os.getenv "HOME" .. "/.config/mzte_localconf/" .. id
local file = io.open(path, "r")
if file == nil then
if not file then
return ""
end
return file:read "*a"
end
local local_opts = loadfile(os.getenv "HOME" .. "/.config/mzte_localconf/opts.lua")
-- Returns the contents of a file
cg.opt.read = function(fname)
local file = io.open(fname, "r")
if not file then
return nil
end
if local_opts then
cg.opt = merge(cg.opt, local_opts())
return file:read "*a"
end
-- Get the output of a system command