Extract host specific hammerspoon config to separate files

This commit is contained in:
2018-04-29 16:27:55 +01:00
parent 556960a588
commit 4eddfdf6ac
5 changed files with 65 additions and 41 deletions

View File

@@ -0,0 +1,20 @@
local obj = {}
function obj:init()
local env = require('env')
local conf_file = "hosts/" .. env.hostname .. ".lua"
local conf_req = "hosts." .. env.hostname
if self.file_exists(conf_file) then
print("loading host config: " .. conf_file)
local conf_module = require(conf_req)
conf_module:init()
end
end
function obj.file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
return obj