Regenerated
This commit is contained in:
@@ -1,11 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
WALLS=("${HOME}/Wallpapers"/*)
|
||||
NUM_WALLS=${#WALLS[@]}
|
||||
set -euo pipefail
|
||||
|
||||
# Get workspace IDs
|
||||
WS_IDS=($(hyprctl workspaces -j | jq -r '.[].id'))
|
||||
# Determine repo root dynamically
|
||||
repoRoot="$(dirname "$(readlink -f "$0")")/../.."
|
||||
wallpaperSrc="$repoRoot/assets/Wallpapers"
|
||||
wallpaperDst="$HOME/Wallpapers"
|
||||
|
||||
for i in "${!WS_IDS[@]}"; do
|
||||
WALL="${WALLS[$((i % NUM_WALLS))]}"
|
||||
swww img "$WALL" --workspace "${WS_IDS[$i]}" --transition-type fade slide blend zoom wipe cube fade-zoom slide-zoom
|
||||
done
|
||||
mkdir -p "$wallpaperDst"
|
||||
|
||||
# 2-way sync (add only, overwrite if newer, never delete)
|
||||
rsync -au --ignore-existing "$wallpaperSrc/" "$wallpaperDst/"
|
||||
rsync -tu "$wallpaperDst/" "$wallpaperSrc/"
|
||||
|
||||
# Gather wallpapers
|
||||
mapfile -t wallpapers < <(find "$wallpaperDst" -type f)
|
||||
numWallpapers=${#wallpapers[@]}
|
||||
|
||||
if [[ $numWallpapers -eq 0 ]]; then
|
||||
echo "No wallpapers found in $wallpaperDst"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if a workspace ID is passed
|
||||
if [[ $# -eq 1 ]]; then
|
||||
ws="$1"
|
||||
randomIndex=$(( RANDOM % numWallpapers ))
|
||||
swww img "${wallpapers[$randomIndex]}" --transition-fade 1 --workspace "$ws"
|
||||
else
|
||||
# Full refresh for all workspaces
|
||||
workspaces=$(hyprctl workspaces -j | jq -r '.[].id')
|
||||
for ws in $workspaces; do
|
||||
randomIndex=$(( RANDOM % numWallpapers ))
|
||||
swww img "${wallpapers[$randomIndex]}" --transition-fade 1 --workspace "$ws"
|
||||
done
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user