SimpleConkyScript/conky.lua

36 lines
1.6 KiB
Lua

-- HorlogeSkynet's Lua script (for Conky) -- Conky configuration file
-- <https://git.forestier.app/HorlogeSkynet/SimpleConkyScript.git>
-- Locations of the project directory and Lua scripts.
local project_path = (os.getenv('CONKY_PATH') or (os.getenv('HOME') .. "/.conky/SimpleConkyScript"))
if string.sub(project_path, -1) ~= '/' then project_path = project_path .. '/' end
local lua_sources = project_path .. "lua/"
-- Instantiate and populate a (first) `config` singleton.
-- We voluntary use an `assert` here to make Conky output a clear error message when `loadfile` failed.
local config = assert(loadfile(lua_sources .. 'config.lua'))(project_path)
-- Manually load the `system` module, by passing the `config` object to it.
local system = loadfile(lua_sources .. 'system.lua')(config)
-- Fetch basic settings from the user externalized configuration file.
conky.config = config.get_entries('settings').conky
-- For future computations, fetch the current screen dimensions.
local width, height = system.get_screen_resolution()
-- Manually configure the surface dimensions, based on the user-defined gaps.
conky.config['minimum_width'] = width - (2 * conky.config['gap_x'])
conky.config['minimum_height'] = height - (2 * conky.config['gap_y'])
-- Manually add our own Lua-relative stuffs.
conky.config['lua_load'] = (lua_sources .. 'main.lua')
conky.config['lua_draw_hook_pre'] = string.format("main %s %d %d", project_path, width, height)
conky.config['lua_startup_hook'] = string.format("startup %s", project_path)
-- Only Lua instructions will be executed, so the `text` content is left empty.
conky.text = [[]]