From 1ee02f2a2f748c1edaf0b3e006873742b2301df6 Mon Sep 17 00:00:00 2001 From: SirBlobby Date: Mon, 20 Apr 2026 20:12:48 -0400 Subject: [PATCH] Integrate visual image previews using custom walker/elephant provider --- elephant/menus/blob_background_selector.lua | 57 +++++++++++++++++++++ install.sh | 2 + scripts/blob_wallpaper.sh | 10 +--- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 elephant/menus/blob_background_selector.lua diff --git a/elephant/menus/blob_background_selector.lua b/elephant/menus/blob_background_selector.lua new file mode 100644 index 0000000..f7b4f17 --- /dev/null +++ b/elephant/menus/blob_background_selector.lua @@ -0,0 +1,57 @@ +Name = "blobBackgroundSelector" +NamePretty = "Blob's Background Selector" +Cache = false +HideFromProviderlist = true +SearchName = true + +local function ShellEscape(s) + return "'" .. s:gsub("'", "'\\''") .. "'" +end + +function FormatName(filename) + local name = filename:gsub("^%d+", ""):gsub("^%-", "") + name = name:gsub("%.[^%.]+$", "") + name = name:gsub("-", " ") + name = name:gsub("%S+", function(word) + return word:sub(1, 1):upper() .. word:sub(2):lower() + end) + return name +end + +function GetEntries() + local entries = {} + local home = os.getenv("HOME") + + local dirs = { + home .. "/wallpapers", + } + + local seen = {} + + for _, wallpaper_dir in ipairs(dirs) do + local handle = io.popen( + "find " .. ShellEscape(wallpaper_dir) + .. " -maxdepth 1 -type f \\( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' -o -name '*.gif' -o -name '*.bmp' -o -name '*.webp' \\) 2>/dev/null | sort" + ) + if handle then + for background in handle:lines() do + local filename = background:match("([^/]+)$") + if filename and not seen[filename] then + seen[filename] = true + table.insert(entries, { + Text = FormatName(filename), + Value = filename, + Actions = { + activate = "blob_wallpaper " .. ShellEscape(background), + }, + Preview = background, + PreviewType = "file", + }) + end + end + handle:close() + end + end + + return entries +end \ No newline at end of file diff --git a/install.sh b/install.sh index 2b2320d..0a6516d 100755 --- a/install.sh +++ b/install.sh @@ -137,6 +137,7 @@ check_file "$SCRIPT_DIR/ags/app.ts" "$HOME_DIR/.config/ags/app.ts" "ags/app.ts" check_file "$SCRIPT_DIR/ags/style.css" "$HOME_DIR/.config/ags/style.css" "ags/style.css" || check_status=1 check_file "$SCRIPT_DIR/ags/widget/Media.tsx" "$HOME_DIR/.config/ags/widget/Media.tsx" "ags/widget/Media.tsx" || check_status=1 check_file "$SCRIPT_DIR/waybar/style.css" "$HOME_DIR/.config/waybar/style.css" "waybar/style.css" || check_status=1 +check_file "$SCRIPT_DIR/elephant/menus/blob_background_selector.lua" "$HOME_DIR/.config/elephant/menus/blob_background_selector.lua" "elephant/menus/blob_background_selector.lua" || check_status=1 check_file "$SCRIPT_DIR/branding/about.txt" "$HOME_DIR/.config/omarchy/branding/about.txt" "branding/about.txt" || check_status=1 check_file "$SCRIPT_DIR/branding/screensaver.txt" "$HOME_DIR/.config/omarchy/branding/screensaver.txt" "branding/screensaver.txt" || check_status=1 @@ -171,6 +172,7 @@ backup_and_copy "$SCRIPT_DIR/waybar" "$HOME_DIR/.config/waybar" "Waybar config" backup_and_copy "$SCRIPT_DIR/ags" "$HOME_DIR/.config/ags" "AGS config" backup_and_copy "$SCRIPT_DIR/hypr" "$HOME_DIR/.config/hypr" "Hyprland config" backup_and_copy "$SCRIPT_DIR/branding" "$HOME_DIR/.config/omarchy/branding" "Branding files" +backup_and_copy "$SCRIPT_DIR/elephant" "$HOME_DIR/.config/elephant" "Elephant configs" backup_and_copy "$SCRIPT_DIR/omarchy/hooks" "$HOME_DIR/.config/omarchy/hooks" "Omarchy hooks" backup_and_copy "$SCRIPT_DIR/wallpapers" "$HOME_DIR/wallpapers" "Custom wallpapers" diff --git a/scripts/blob_wallpaper.sh b/scripts/blob_wallpaper.sh index 066940e..38149b8 100755 --- a/scripts/blob_wallpaper.sh +++ b/scripts/blob_wallpaper.sh @@ -9,14 +9,8 @@ mkdir -p "$THEME_DIR/backgrounds" if [ -z "$1" ]; then # Use walker dmenu for GUI selection - SELECTED_FILE=$(ls -1 "$WALLPAPER_DIR" 2>/dev/null | omarchy-launch-walker --dmenu -p "Select Wallpaper") - - if [ -z "$SELECTED_FILE" ]; then - echo "No wallpaper selected." - exit 0 - fi - - IMAGE_PATH=$(realpath "$WALLPAPER_DIR/$SELECTED_FILE") + omarchy-launch-walker -m menus:blobBackgroundSelector --width 800 --minheight 400 -p "Select Wallpaper…" + exit 0 else # Check if the argument is a file in the wallpapers directory if [ -f "$WALLPAPER_DIR/$1" ]; then