added comments for casual readers
This commit is contained in:
23
autoload.lua
23
autoload.lua
@@ -1,22 +1,22 @@
|
||||
local hyprRoot
|
||||
local modules
|
||||
|
||||
if os.getenv("HYPRLAND_ROOT") then
|
||||
hyprRoot = os.getenv("HYPRLAND_ROOT")
|
||||
else
|
||||
hyprRoot = os.getenv("Home") .. "/.config/hypr"
|
||||
end
|
||||
|
||||
modules = hyprRoot .. "/modules"
|
||||
-- Use global HyprRoot to extrappolate modules
|
||||
local modules = HyprRoot .. "/modules"
|
||||
|
||||
-- Proccess to find all files ending in ".lua" in the modules directory,
|
||||
-- returning in alphabetical order. Directories are excluded and subdirectories
|
||||
-- in the module directory are also searched.
|
||||
local p = io.popen('find -L "' .. modules .. '" -name "*.lua" -type f | sort')
|
||||
-- If p is empty or the command fails (modules dir doesnt exist), return no modules
|
||||
if not p then
|
||||
return
|
||||
end
|
||||
|
||||
-- for every line in p stdout
|
||||
for path in p:lines() do
|
||||
-- Touple to call the file
|
||||
local ok, error = pcall(dofile, path)
|
||||
-- If the file cannot be called (syntax error, doesn't exist, etc.)
|
||||
if not ok then
|
||||
-- Notify the user with the information
|
||||
hl.notification.create({
|
||||
text = "autoload: " .. path .. "\n" .. tostring(error),
|
||||
timeout = 8000,
|
||||
@@ -24,3 +24,6 @@ for path in p:lines() do
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- When all files have been called, kill hanging function
|
||||
p:close()
|
||||
|
||||
Reference in New Issue
Block a user