From eb7513b2f66fd2b7d4d6e02c81db468512838e32 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sat, 21 Jan 2023 00:01:23 +0100 Subject: [PATCH] add local conf feature to confgen.lua --- .config/gtk-3.0/.gitignore | 1 - .config/i3/config.cgt | 1 + .config/touchegg/.gitignore | 1 - confgen.lua | 12 ++++++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) delete mode 100644 .config/gtk-3.0/.gitignore delete mode 100644 .config/touchegg/.gitignore diff --git a/.config/gtk-3.0/.gitignore b/.config/gtk-3.0/.gitignore deleted file mode 100644 index 7e1f6a7..0000000 --- a/.config/gtk-3.0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bookmarks diff --git a/.config/i3/config.cgt b/.config/i3/config.cgt index 77181f8..ab9a4f9 100644 --- a/.config/i3/config.cgt +++ b/.config/i3/config.cgt @@ -278,3 +278,4 @@ bar { } } +<% opt.getDeviceConf("i3") %> diff --git a/.config/touchegg/.gitignore b/.config/touchegg/.gitignore deleted file mode 100644 index 63f1fef..0000000 --- a/.config/touchegg/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.lock diff --git a/confgen.lua b/confgen.lua index 7a1bbab..cbd5015 100644 --- a/confgen.lua +++ b/confgen.lua @@ -6,3 +6,15 @@ cg.addPath ".cargo" for k, v in pairs(require "cg_opts") do cg.opt[k] = v 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 + return "" + end + + return file:read "*a" +end