diff --git a/hammerspoon/host_config.lua b/hammerspoon/host_config.lua index ee884e9..c72fca0 100644 --- a/hammerspoon/host_config.lua +++ b/hammerspoon/host_config.lua @@ -1,21 +1,17 @@ -local host = require('hs.host') - local function require_file(path) - local modulename = string.gsub(path, "/", "."):gsub("%.lua$", "") - local ok, module = pcall(require, modulename) - - return (ok and module or nil) + local ok, module = pcall(loadfile, path) + return (ok and module and module() or nil) end local obj = {} function obj:init() - local hostname = host.localizedName() - local conf_file = "hosts/" .. hostname .. ".lua" + local hostname = hs.host.localizedName() + local conf_file = 'hosts/' .. hostname .. '.lua' local hostmod = require_file(conf_file) if hostmod then - print("loading host config: " .. conf_file) + print('loading host config: ' .. conf_file) hostmod.init() end end