diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 55b27f8a..a36d8955 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -181,7 +181,7 @@ show_style_menu() { case $(menu "Style" "󰸌 Theme\n Font\n Background\n Hyprland\n󱄄 Screensaver\n About") in *Theme*) show_theme_menu ;; *Font*) show_font_menu ;; - *Background*) omarchy-theme-bg-next ;; + *Background*) show_background_menu ;; *Hyprland*) open_in_editor ~/.config/hypr/looknfeel.conf ;; *Screensaver*) open_in_editor ~/.config/omarchy/branding/screensaver.txt ;; *About*) open_in_editor ~/.config/omarchy/branding/about.txt ;; @@ -193,6 +193,10 @@ show_theme_menu() { omarchy-launch-walker -m menus:omarchythemes --width 800 --minheight 400 } +show_background_menu() { + omarchy-launch-walker -m menus:omarchyBackgroundSelector +} + show_font_menu() { theme=$(menu "Font" "$(omarchy-font-list)" "--width 350" "$(omarchy-font-current)") if [[ "$theme" == "CNCLD" || -z "$theme" ]]; then @@ -584,6 +588,7 @@ go_to_menu() { *learn*) show_learn_menu ;; *trigger*) show_trigger_menu ;; *share*) show_share_menu ;; + *background*) show_background_menu ;; *capture*) show_capture_menu ;; *style*) show_style_menu ;; *theme*) show_theme_menu ;; diff --git a/bin/omarchy-theme-bg-set b/bin/omarchy-theme-bg-set new file mode 100755 index 00000000..0b13ef0b --- /dev/null +++ b/bin/omarchy-theme-bg-set @@ -0,0 +1,18 @@ +#!/bin/bash + +# Sets the specified image as the current background + +if [[ -z "$1" ]]; then + echo "Usage: omarchy-theme-bg-set " >&2 + exit 1 +fi + +BACKGROUND="$1" +CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background" + +# Create symlink to the new background +ln -nsf "$BACKGROUND" "$CURRENT_BACKGROUND_LINK" + +# Kill existing swaybg and start new one +pkill -x swaybg +setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 & diff --git a/bin/omarchy-theme-set b/bin/omarchy-theme-set index 29ad774a..83fd263a 100755 --- a/bin/omarchy-theme-set +++ b/bin/omarchy-theme-set @@ -33,7 +33,7 @@ rm -rf "$CURRENT_THEME_PATH" mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH" # Store theme name for reference -echo "$THEME_NAME" > "$HOME/.config/omarchy/current/theme.name" +echo "$THEME_NAME" >"$HOME/.config/omarchy/current/theme.name" # Change background with theme omarchy-theme-bg-next @@ -48,6 +48,7 @@ omarchy-restart-hyprctl omarchy-restart-btop omarchy-restart-opencode omarchy-restart-mako +omarchy-restart-walker # Change app-specific themes omarchy-theme-set-gnome diff --git a/default/elephant/omarchy_background_selector.lua b/default/elephant/omarchy_background_selector.lua new file mode 100644 index 00000000..bf614954 --- /dev/null +++ b/default/elephant/omarchy_background_selector.lua @@ -0,0 +1,56 @@ +Name = "omarchyBackgroundSelector" +NamePretty = "Omarchy Background Selector" +Cache = false +HideFromProviderlist = true +SearchName = true + +function GetEntries() + local entries = {} + local home = os.getenv("HOME") + + -- Read current theme name + local theme_name_file = io.open(home .. "/.config/omarchy/current/theme.name", "r") + local theme_name = theme_name_file and theme_name_file:read("*l") or nil + if theme_name_file then + theme_name_file:close() + end + + -- Directories to search + local dirs = { + home .. "/.config/omarchy/current/theme/backgrounds", + } + if theme_name then + table.insert(dirs, home .. "/.config/omarchy/backgrounds/" .. theme_name) + end + + -- Track added files to avoid duplicates + local seen = {} + + for _, wallpaper_dir in ipairs(dirs) do + local handle = io.popen( + "find '" + .. 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" + ) + 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 = filename, + Value = background, + Actions = { + activate = "omarchy-theme-bg-set '" .. background .. "'", + }, + Preview = background, + PreviewType = "file", + }) + end + end + handle:close() + end + end + + return entries +end diff --git a/default/hypr/bindings/utilities.conf b/default/hypr/bindings/utilities.conf index 06f38c83..86e1c808 100644 --- a/default/hypr/bindings/utilities.conf +++ b/default/hypr/bindings/utilities.conf @@ -10,7 +10,7 @@ bindd = , XF86Calculator, Calculator, exec, gnome-calculator # Aesthetics bindd = SUPER SHIFT, SPACE, Toggle top bar, exec, omarchy-toggle-waybar -bindd = SUPER CTRL, SPACE, Next background in theme, exec, omarchy-theme-bg-next +bindd = SUPER CTRL, SPACE, Next background in theme, exec, omarchy-menu background bindd = SUPER SHIFT CTRL, SPACE, Theme menu, exec, omarchy-menu theme bindd = SUPER, BACKSPACE, Toggle window transparency, exec, hyprctl dispatch setprop "address:$(hyprctl activewindow -j | jq -r '.address')" opaque toggle bindd = SUPER SHIFT, BACKSPACE, Toggle workspace gaps, exec, omarchy-hyprland-workspace-toggle-gaps diff --git a/install/config/walker-elephant.sh b/install/config/walker-elephant.sh index de924d4c..ad071dc9 100644 --- a/install/config/walker-elephant.sh +++ b/install/config/walker-elephant.sh @@ -27,3 +27,4 @@ EOF # Link the visual theme menu config mkdir -p ~/.config/elephant/menus ln -snf $OMARCHY_PATH/default/elephant/omarchy_themes.lua ~/.config/elephant/menus/omarchy_themes.lua +ln -snf $OMARCHY_PATH/default/elephant/omarchy_background_selector.lua ~/.config/elephant/menus/omarchy_background_selector.lua diff --git a/migrations/1770380577.sh b/migrations/1770380577.sh new file mode 100644 index 00000000..a9b0ca8b --- /dev/null +++ b/migrations/1770380577.sh @@ -0,0 +1,5 @@ +echo "Use interactive background selector menu" + +mkdir -p ~/.config/elephant/menus +ln -snf $OMARCHY_PATH/default/elephant/omarchy_background_selector.lua ~/.config/elephant/menus/omarchy_background_selector.lua +omarchy-restart-walker