From 0426f9b206b6d18cd337a1adf662acf3f3781959 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 11 May 2026 18:07:09 +0200 Subject: [PATCH] Cache warming --- bin/omarchy-menu-images | 15 ++++++++++++--- bin/omarchy-theme-bg-cache | 10 ++++++++++ bin/omarchy-theme-set | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 bin/omarchy-theme-bg-cache diff --git a/bin/omarchy-menu-images b/bin/omarchy-menu-images index f76cf6ea..e5909560 100755 --- a/bin/omarchy-menu-images +++ b/bin/omarchy-menu-images @@ -1,13 +1,14 @@ #!/bin/bash # omarchy:summary=Open a generic image selector menu -# omarchy:args=[--selected ] [--colors-file ] [--print-name] ... +# omarchy:args=[--selected ] [--colors-file ] [--print-name] [--cache-only] ... OMARCHY_PATH=${OMARCHY_PATH:-$HOME/.local/share/omarchy} selected_image="" colors_file="" print_name=false +cache_only=false image_dirs=() while [[ $# -gt 0 ]]; do @@ -24,8 +25,12 @@ while [[ $# -gt 0 ]]; do print_name=true shift ;; + --cache-only) + cache_only=true + shift + ;; --help|-h) - echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] ..." + echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--cache-only] ..." exit 0 ;; *) @@ -36,7 +41,7 @@ while [[ $# -gt 0 ]]; do done if (( ${#image_dirs[@]} == 0 )); then - echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] ..." >&2 + echo "Usage: omarchy-menu-images [--selected ] [--colors-file ] [--print-name] [--cache-only] ..." >&2 exit 1 fi @@ -133,6 +138,10 @@ fi rows_payload=${rows//$'\t'/$'\f'} rows_payload=${rows_payload//$'\n'/$'\v'} +if [[ $cache_only == true ]]; then + exit 0 +fi + if [[ -S $socket_path && $selector_qml -nt $socket_path ]]; then quickshell kill -p "$selector_qml" >/dev/null 2>&1 || true rm -f "$socket_path" diff --git a/bin/omarchy-theme-bg-cache b/bin/omarchy-theme-bg-cache new file mode 100755 index 00000000..4564e5bd --- /dev/null +++ b/bin/omarchy-theme-bg-cache @@ -0,0 +1,10 @@ +#!/bin/bash + +# omarchy:summary=Cache background switcher thumbnails for the current theme + +theme_name=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null) + +omarchy-menu-images \ + --cache-only \ + "$HOME/.config/omarchy/current/theme/backgrounds" \ + "$HOME/.config/omarchy/backgrounds/$theme_name" diff --git a/bin/omarchy-theme-set b/bin/omarchy-theme-set index fe57c2af..8dafed8b 100755 --- a/bin/omarchy-theme-set +++ b/bin/omarchy-theme-set @@ -71,3 +71,6 @@ omarchy-theme-set-keyboard # Call hook on theme set omarchy-hook theme-set "$THEME_NAME" >/dev/null + +# Warm the background selector cache after the theme is applied, off the critical path. +omarchy-theme-bg-cache >/dev/null 2>&1 &