From f45bdf5e469be8057fbf74f0c427a66c49a157f5 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 19 Jun 2025 08:10:23 -0400 Subject: [PATCH] Extract background installation and do it all upfront --- install/backgrounds.sh | 9 +++++++++ themes/catppuccin/backgrounds.sh | 8 ++------ themes/everforest/backgrounds.sh | 8 ++------ themes/gruvbox/backgrounds.sh | 8 ++------ themes/kanagawa/backgrounds.sh | 8 ++------ themes/nord/backgrounds.sh | 8 ++------ themes/tokyo-night/backgrounds.sh | 12 ++++-------- 7 files changed, 23 insertions(+), 38 deletions(-) create mode 100644 install/backgrounds.sh diff --git a/install/backgrounds.sh b/install/backgrounds.sh new file mode 100644 index 0000000..a1737a4 --- /dev/null +++ b/install/backgrounds.sh @@ -0,0 +1,9 @@ +BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/ + +download_background_image() { + local url="$1" + local path="$2" + gum spin --title "Downloading background image..." -- curl -sL -o "$BACKGROUNDS_DIR/$path" "$url" +} + +for t in ~/.local/share/omarchy/themes/*; do source "$t/backgrounds.sh"; done diff --git a/themes/catppuccin/backgrounds.sh b/themes/catppuccin/backgrounds.sh index 8757069..fbe69d0 100644 --- a/themes/catppuccin/backgrounds.sh +++ b/themes/catppuccin/backgrounds.sh @@ -1,6 +1,2 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/catppuccin - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-catppuccin.png https://github.com/basecamp/omakub/raw/refs/heads/master/themes/catppuccin/background.png -fi +mkdir -p "$BACKGROUNDS_DIR/catppuccin" +download_background_image "https://github.com/basecamp/omakub/raw/refs/heads/master/themes/catppuccin/background.png", "catppuccin/1-catppuccin.png" diff --git a/themes/everforest/backgrounds.sh b/themes/everforest/backgrounds.sh index 28a7087..d3e0b17 100644 --- a/themes/everforest/backgrounds.sh +++ b/themes/everforest/backgrounds.sh @@ -1,6 +1,2 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/everforest - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-everforest.jpg https://github.com/basecamp/omakub/raw/refs/heads/master/themes/everforest/background.jpg -fi +mkdir -p "$BACKGROUNDS_DIR/everforest" +download_background_image "https://github.com/basecamp/omakub/raw/refs/heads/master/themes/everforest/background.jpg", "everforest/1-everforest.jpg" diff --git a/themes/gruvbox/backgrounds.sh b/themes/gruvbox/backgrounds.sh index 2424485..cc7f705 100644 --- a/themes/gruvbox/backgrounds.sh +++ b/themes/gruvbox/backgrounds.sh @@ -1,6 +1,2 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/gruvbox - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-gruvbox.jpg https://github.com/basecamp/omakub/raw/refs/heads/master/themes/gruvbox/background.jpg -fi +mkdir -p "$BACKGROUNDS_DIR/gruvbox" +download_background_image "https://github.com/basecamp/omakub/raw/refs/heads/master/themes/gruvbox/background.jpg", "gruvbox/1-grubox.jpg" diff --git a/themes/kanagawa/backgrounds.sh b/themes/kanagawa/backgrounds.sh index 1aee3c8..202045b 100644 --- a/themes/kanagawa/backgrounds.sh +++ b/themes/kanagawa/backgrounds.sh @@ -1,6 +1,2 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/kanagawa - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-kanagawa.jpg https://github.com/basecamp/omakub/raw/refs/heads/master/themes/kanagawa/background.jpg -fi +mkdir -p "$BACKGROUNDS_DIR/kanagawa" +download_background_image "https://github.com/basecamp/omakub/raw/refs/heads/master/themes/kanagawa/background.jpg", "kanagawa/1-kanagawa.jpg" diff --git a/themes/nord/backgrounds.sh b/themes/nord/backgrounds.sh index 497a77c..261489b 100644 --- a/themes/nord/backgrounds.sh +++ b/themes/nord/backgrounds.sh @@ -1,6 +1,2 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/nord - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-nord.png https://github.com/basecamp/omakub/raw/refs/heads/master/themes/nord/background.png -fi +mkdir -p "$BACKGROUNDS_DIR/nord" +download_background_image "https://github.com/basecamp/omakub/raw/refs/heads/master/themes/nord/background.png", "nord/1-nord.png" diff --git a/themes/tokyo-night/backgrounds.sh b/themes/tokyo-night/backgrounds.sh index 6fe5bf9..43f130f 100644 --- a/themes/tokyo-night/backgrounds.sh +++ b/themes/tokyo-night/backgrounds.sh @@ -1,8 +1,4 @@ -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/tokyo-night - -if [[ ! -d $BACKGROUNDS_DIR ]]; then - mkdir -p $BACKGROUNDS_DIR - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/1-Milad-Fakurian-Abstract-Purple-Blue.jpg https://images.unsplash.com/photo-1620207418302-439b387441b0 - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/2-Pawel-Czerwinski-Abstract-Purple-Blue.jpg https://images.unsplash.com/photo-1651870364199-fc5f9f46ac85 - gum spin --title "Downloading background image..." -- curl -sL -o $BACKGROUNDS_DIR/3-Jr-Korpa-Abstract-Purple-Blue.jpg https://images.unsplash.com/flagged/photo-1567400358593-9e6382752ea2 -fi +mkdir -p "$BACKGROUNDS_DIR/tokyo-night" +download_background_image "https://images.unsplash.com/photo-1620207418302-439b387441b0", "tokyo-night/1-Milad-Fakurian-Abstract-Purple-Blue.jpg" +download_background_image "https://images.unsplash.com/photo-1651870364199-fc5f9f46ac85", "tokyo-night/2-Pawel-Czerwinski-Abstract-Purple-Blue.jpg" +download_background_image "https://images.unsplash.com/photo-1567400358593-9e6382752ea2", "tokyo-night/3-Jr-Korpa-Abstract-Purple-Blue.jpg"