mirror of
https://github.com/basecamp/omarchy.git
synced 2025-07-28 04:39:25 +00:00
Change background setup to cycle
This commit is contained in:
22
bin/swaybg-next
Executable file
22
bin/swaybg-next
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Cycles through the background images available
|
||||
|
||||
BACKGROUNDS_DIR="$HOME/.local/share/backgrounds"
|
||||
NEXT_BACKGROUND_FILE="$HOME/.cache/next_background_index"
|
||||
|
||||
BACKGROUNDS=($(find "$BACKGROUNDS_DIR" -type f | sort))
|
||||
TOTAL=${#BACKGROUNDS[@]}
|
||||
|
||||
if [[ ! -f "$NEXT_BACKGROUND_FILE" ]]; then
|
||||
INDEX=0
|
||||
else
|
||||
INDEX=$(<"$NEXT_BACKGROUND_FILE")
|
||||
fi
|
||||
|
||||
# Save next index (wrap around)
|
||||
echo "$(( (INDEX + 1) % TOTAL ))" > "$NEXT_BACKGROUND_FILE"
|
||||
|
||||
# Launch swaybg
|
||||
pkill -x swaybg
|
||||
setsid swaybg -i "${BACKGROUNDS[$INDEX]}" -m fill >/dev/null 2>&1 &
|
Reference in New Issue
Block a user