Some checks failed
Check / eval-and-lint (push) Failing after 6m40s
Pillar 9 VM test: the walker theme picker (and background selector) returned "No Results". Root cause: nomarchy_themes.lua and nomarchy_background_selector.lua (elephant lua menu providers named "nomarchythemes" / "nomarchyBackgroundSelector") were deployed via the bulk nomarchy config to ~/.config/nomarchy/default/elephant/ — outside elephant's provider search path, so elephant never registered them and `nomarchy-launch-walker -m menus:nomarchythemes` (used by nomarchy-theme, nomarchy-wallpaper, and nomarchy-menu Style submenu) had no backing menu. Move them into the elephant config (features/apps/elephant/config/menus/) so they deploy to ~/.config/elephant/menus/. Verified on a fresh VM boot: `elephant listproviders` now lists menus:nomarchythemes + menus:nomarchyBackgroundSelector, and the walker theme picker renders all 21 palettes with per-theme preview images. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
96 lines
2.8 KiB
Lua
96 lines
2.8 KiB
Lua
--
|
|
-- Dynamic Nomarchy Theme Menu for Elephant/Walker
|
|
--
|
|
Name = "nomarchythemes"
|
|
NamePretty = "Nomarchy Themes"
|
|
HideFromProviderlist = true
|
|
|
|
-- Check if file exists using Lua (no subprocess)
|
|
local function file_exists(path)
|
|
local f = io.open(path, "r")
|
|
if f then
|
|
f:close()
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- Get first matching file from directory using ls (single call for fallback)
|
|
local function first_image_in_dir(dir)
|
|
local handle = io.popen("ls -1 '" .. dir .. "' 2>/dev/null | head -n 1")
|
|
if handle then
|
|
local file = handle:read("*l")
|
|
handle:close()
|
|
if file and file ~= "" then
|
|
return dir .. "/" .. file
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
-- The main function elephant will call
|
|
function GetEntries()
|
|
local entries = {}
|
|
local user_theme_dir = os.getenv("HOME") .. "/.config/nomarchy/themes"
|
|
local default_theme_dir = os.getenv("HOME") .. "/.local/share/nomarchy/themes"
|
|
|
|
local seen_themes = {}
|
|
|
|
-- Helper function to process themes from a directory
|
|
local function process_themes_from_dir(theme_dir)
|
|
-- Single find call to get all theme directories
|
|
local handle = io.popen("find -L '" .. theme_dir .. "' -mindepth 1 -maxdepth 1 -type d 2>/dev/null")
|
|
if not handle then
|
|
return
|
|
end
|
|
|
|
for theme_path in handle:lines() do
|
|
local theme_name = theme_path:match(".*/(.+)$")
|
|
|
|
if theme_name and not seen_themes[theme_name] then
|
|
seen_themes[theme_name] = true
|
|
|
|
-- Check for preview images directly (no subprocess)
|
|
local preview_path = nil
|
|
local preview_png = theme_path .. "/preview.png"
|
|
local preview_jpg = theme_path .. "/preview.jpg"
|
|
|
|
if file_exists(preview_png) then
|
|
preview_path = preview_png
|
|
elseif file_exists(preview_jpg) then
|
|
preview_path = preview_jpg
|
|
else
|
|
-- Fallback: get first image from backgrounds (one ls call)
|
|
preview_path = first_image_in_dir(theme_path .. "/backgrounds")
|
|
end
|
|
|
|
if preview_path and preview_path ~= "" then
|
|
local display_name = theme_name:gsub("_", " "):gsub("%-", " ")
|
|
display_name = display_name:gsub("(%a)([%w_']*)", function(first, rest)
|
|
return first:upper() .. rest:lower()
|
|
end)
|
|
display_name = display_name .. " "
|
|
|
|
table.insert(entries, {
|
|
Text = display_name,
|
|
Preview = preview_path,
|
|
PreviewType = "file",
|
|
Actions = {
|
|
activate = "nomarchy-theme-set " .. theme_name,
|
|
},
|
|
})
|
|
end
|
|
end
|
|
end
|
|
|
|
handle:close()
|
|
end
|
|
|
|
-- Process user themes first (they take precedence)
|
|
process_themes_from_dir(user_theme_dir)
|
|
-- Then process default themes (only if not already seen)
|
|
process_themes_from_dir(default_theme_dir)
|
|
|
|
return entries
|
|
end
|