#!/usr/bin/env bash set -euo pipefail # ----------------------------- # CONFIGURATION # ----------------------------- # Repo path (first argument), fallback to current dir REPO_DIR="${1:-$HOME/myrepo}" SRC_WALLPAPERS="$REPO_DIR/assets/Wallpapers" DST_WALLPAPERS="$HOME/Wallpapers" PICTURES_DIR="$DST_WALLPAPERS/pictures" # ----------------------------- # 2-WAY SYNC (only add/update, never delete) # ----------------------------- mkdir -p "$DST_WALLPAPERS" mkdir -p "$PICTURES_DIR" # Sync from repo -> home (add/update) rsync -au --ignore-existing "$SRC_WALLPAPERS/" "$DST_WALLPAPERS/" # Sync from home -> repo (add only, no deletion) rsync -au --ignore-existing "$DST_WALLPAPERS/" "$SRC_WALLPAPERS/" # ----------------------------- # Set random wallpaper per workspace # ----------------------------- # Get list of images mapfile -t IMAGES < <(find "$PICTURES_DIR" -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \)) if [ "${#IMAGES[@]}" -eq 0 ]; then echo "No images found in $PICTURES_DIR" exit 1 fi # Get number of workspaces (Hyprland / swww) NUM_WORKSPACES=$(hyprctl workspaces | wc -l) for ws in $(seq 1 "$NUM_WORKSPACES"); do # Pick a random image RAND_IMAGE="${IMAGES[RANDOM % ${#IMAGES[@]}]}" # Set wallpaper for workspace swww img "$RAND_IMAGE" --no-fade --transition-type none --workspace "$ws" done