From fc258fa8b2eb6052f7668e30eda43b2640c714f3 Mon Sep 17 00:00:00 2001 From: Stitch <60798723+maxwell7774@users.noreply.github.com> Date: Wed, 22 Apr 2026 07:52:49 -0600 Subject: [PATCH] Elephant menu fix when using customized default themes (#4953) * Adds a check to see if the default theme has a preview if the user customized default theme lacks one. * Update default/elephant/omarchy_themes.lua Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Reduce duplication --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: David Heinemeier Hansson --- default/elephant/omarchy_themes.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/default/elephant/omarchy_themes.lua b/default/elephant/omarchy_themes.lua index 945f4e60..e892f3e4 100644 --- a/default/elephant/omarchy_themes.lua +++ b/default/elephant/omarchy_themes.lua @@ -28,6 +28,15 @@ local function first_image_in_dir(dir) return nil end +-- Find preview.png, preview.jpg, or first backgrounds/ image in a theme dir +local function find_preview_path(dir) + local png = dir .. "/preview.png" + local jpg = dir .. "/preview.jpg" + if file_exists(png) then return png end + if file_exists(jpg) then return jpg end + return first_image_in_dir(dir .. "/backgrounds") +end + -- The main function elephant will call function GetEntries() local entries = {} @@ -51,19 +60,10 @@ function GetEntries() 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 + -- Check the theme dir, then fall back to the default theme dir + -- (for partial user customizations that don't ship a preview) + local preview_path = find_preview_path(theme_path) + or find_preview_path(default_theme_dir .. "/" .. theme_name) if preview_path and preview_path ~= "" then local display_name = theme_name:gsub("_", " "):gsub("%-", " ")