-- loadall.lua
-- by @wim66
-- v4.1 May 7, 2025
--
-- 2025-nov-10: Modification by Koentje  (remon@cobrasoft.nl)


-- Set the path to the scripts folder
package.path = "./clockscripts/?.lua"

-- This scipts filename
local SCRIPT_NAME = string.gsub(string.match(debug.getinfo(1, 'S').short_src, "[^/]+$"), '.lua', '')

-- Read settings.ini file
path = ("./settings.ini")
  if io.open(path, "r") == nil then
    print(SCRIPT_NAME .. ".lua: \27[31mNo settings.ini found !\27[m")
    os.execute("pkill -f forecast.conky")
    return
  else
    file = io.open(path) lines = file:lines();
    for line in lines
    do
          local key = {line}
          mykey = string.sub(key[1],1,5)
           if mykey == "cface" then
             cface = string.sub(key[1], 8, -2)
             print("Clockface: " .. cface)
           end
    end
  end


-- Import modules
local success, clock = pcall(require, cface)
 if not success then
   print("Error loading clock module: ".. clock)
 end


-- Main function to draw Conky elements
function conky_main()
--    if background then conky_draw_background() end
    if clock then conky_clock() end
end
