From 0e803e736617ad90d5b02dd0b84b218eef911591 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 15:32:47 +0000 Subject: [PATCH] feat(install): set wallhaven 2133ly as default wallpaper - lib/wallpaper.sh: downloads the default wallpaper at install time (tries .jpg then .png against the wallhaven CDN path) into ~/.config/hypr/wallpapers/default. and writes hyprpaper.conf pointing at it - Override the source with WALLPAPER_URL= or just the URL stem with WALLPAPER_URL_BASE - Existing hyprpaper.conf is backed up to .pre-install. unless it's already ours (marker comment) - files/hypr/autostart.conf: exec-once = hyprpaper - install.sh: wire setup_wallpaper into do_dotfiles_and_config Tried to fetch from this sandbox to verify the extension but wallhaven blocks datacenter IPs (403); the installer probes .jpg first then .png when it actually runs on a residential network. --- install/README.md | 6 ++ install/files/hypr/autostart.conf | 3 +- install/install.sh | 2 + install/lib/wallpaper.sh | 98 +++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 install/lib/wallpaper.sh diff --git a/install/README.md b/install/README.md index 15ff36b..bc79338 100644 --- a/install/README.md +++ b/install/README.md @@ -88,6 +88,12 @@ top-right anchored, JetBrainsMono Nerd Font, per-urgency border colors a rofi-driven menu with Lock / Suspend / Logout / Reboot / Shutdown. Bound to **Super + Shift + E** in Hyprland and to the Waybar power button. +**Wallpaper:** downloads +[wallhaven.cc/w/2133ly](https://wallhaven.cc/w/2133ly) to +`~/.config/hypr/wallpapers/default.jpg` and writes `hyprpaper.conf` pointing +at it. Override with `WALLPAPER_URL=` before running the +installer (any pre-existing `hyprpaper.conf` is backed up first). + **Services enabled:** `sddm`, `NetworkManager`, `bluetooth`; user-level `pipewire`, `pipewire-pulse`, `wireplumber`. diff --git a/install/files/hypr/autostart.conf b/install/files/hypr/autostart.conf index 808fea9..ab86970 100644 --- a/install/files/hypr/autostart.conf +++ b/install/files/hypr/autostart.conf @@ -1,7 +1,8 @@ # Polkit agent for authentication dialogs. exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 -# Top bar + notifications + idle. +# Wallpaper, top bar, notifications, idle. +exec-once = hyprpaper exec-once = waybar exec-once = mako exec-once = hypridle diff --git a/install/install.sh b/install/install.sh index d5621a5..10d84af 100755 --- a/install/install.sh +++ b/install/install.sh @@ -20,6 +20,7 @@ source "$SCRIPT_DIR/lib/common.sh" source "$SCRIPT_DIR/lib/packages.sh" source "$SCRIPT_DIR/lib/dotfiles.sh" source "$SCRIPT_DIR/lib/hyprland.sh" +source "$SCRIPT_DIR/lib/wallpaper.sh" source "$SCRIPT_DIR/lib/services.sh" usage() { @@ -55,6 +56,7 @@ do_packages() { do_dotfiles_and_config() { link_dotfiles link_hyprland_config + setup_wallpaper install_tpm install_nvm set_zsh_as_shell diff --git a/install/lib/wallpaper.sh b/install/lib/wallpaper.sh new file mode 100644 index 0000000..70db0bf --- /dev/null +++ b/install/lib/wallpaper.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Download the default wallpaper and write the hyprpaper config. +# Override the source URL with $WALLPAPER_URL (must be a direct image link). + +# Default: https://wallhaven.cc/w/2133ly (direct CDN path) +DEFAULT_WALLPAPER_BASE="${WALLPAPER_URL_BASE:-https://w.wallhaven.cc/full/21/wallhaven-2133ly}" + +WALLPAPER_DIR="$HOME/.config/hypr/wallpapers" +WALLPAPER_NAME="default" + +download_wallpaper() { + mkdir -p "$WALLPAPER_DIR" + + # If the user passed a fully-qualified URL, honor it directly. + if [[ -n ${WALLPAPER_URL:-} ]]; then + local ext="${WALLPAPER_URL##*.}" + [[ $ext =~ ^(jpg|jpeg|png|webp)$ ]] || ext="jpg" + local target="$WALLPAPER_DIR/$WALLPAPER_NAME.$ext" + if [[ -s $target ]]; then + info "Wallpaper already downloaded: $target" + WALLPAPER_PATH="$target" + return + fi + info "Downloading wallpaper from $WALLPAPER_URL" + curl -fsSL --retry 3 -o "$target" "$WALLPAPER_URL" || { + warn "Wallpaper download failed; hyprpaper will fall back to no wallpaper." + WALLPAPER_PATH="" + return + } + WALLPAPER_PATH="$target" + return + fi + + # Default path: try .jpg then .png against the wallhaven pattern. + local ext target + for ext in jpg png; do + target="$WALLPAPER_DIR/$WALLPAPER_NAME.$ext" + if [[ -s $target ]]; then + info "Wallpaper already downloaded: $target" + WALLPAPER_PATH="$target" + return + fi + done + + for ext in jpg png; do + local url="$DEFAULT_WALLPAPER_BASE.$ext" + target="$WALLPAPER_DIR/$WALLPAPER_NAME.$ext" + info "Trying wallpaper: $url" + if curl -fsSL --retry 2 -o "$target" "$url"; then + WALLPAPER_PATH="$target" + return + fi + rm -f "$target" + done + + warn "Could not download default wallpaper from $DEFAULT_WALLPAPER_BASE.(jpg|png)." + warn "Set WALLPAPER_URL= and re-run install/install.sh --dotfiles-only" + WALLPAPER_PATH="" +} + +write_hyprpaper_config() { + local conf="$HOME/.config/hypr/hyprpaper.conf" + mkdir -p "$(dirname "$conf")" + + # Back up any pre-existing non-empty config (unless it's already ours). + if [[ -s $conf ]] && ! grep -q '^# Generated by dotfiles install/lib/wallpaper.sh' "$conf"; then + local backup="$conf.pre-install.$(date +%s)" + cp "$conf" "$backup" + info "Backed up existing hyprpaper.conf -> $backup" + fi + + if [[ -z ${WALLPAPER_PATH:-} ]]; then + # No image — write a no-op config so hyprpaper starts cleanly. + cat >"$conf" <<'EOF' +# Generated by dotfiles install/lib/wallpaper.sh +# No wallpaper configured. Set WALLPAPER_URL and re-run install.sh, or +# add `preload = ` and `wallpaper = ,` lines below. +splash = false +ipc = on +EOF + info "Wrote stub hyprpaper.conf (no wallpaper)" + return + fi + + cat >"$conf" < $WALLPAPER_PATH" +} + +setup_wallpaper() { + download_wallpaper + write_hyprpaper_config +}