dotfiles/confgen.lua

31 lines
698 B
Lua
Raw Normal View History

cg.addPath ".config"
cg.addPath ".local"
cg.addPath ".ssh"
cg.addPath ".cargo"
2023-01-21 15:14:29 +01:00
cg.addPath "etc"
for k, v in pairs(require "cg_opts") do
cg.opt[k] = v
end
2023-01-21 00:01:23 +01:00
-- 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
return ""
end
return file:read "*a"
end
2023-01-21 15:14:29 +01:00
-- Get the output of a system command
cg.opt.system = function(cmd)
local handle = io.popen(cmd)
if handle == nil then
error("Failed to spawn process" .. cmd)
end
return handle:read("*a"):gsub("%s+", "")
end