Move all omarchy runtime state (themes, backgrounds, current theme) from ~/.config/omarchy/current to ~/.local/state/omarchy/current to keep the config dir free of generated files. Add mise task for recreating symlinks and update credential helpers for tea.
49 lines
1.5 KiB
Bash
Executable File
49 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Cycle to the next background for the current theme
|
|
# omarchy:examples=omarchy theme bg next
|
|
|
|
THEME_NAME=$(cat "$HOME/.local/state/omarchy/current/theme.name" 2>/dev/null)
|
|
THEME_BACKGROUNDS_PATH="$HOME/.local/state/omarchy/current/theme/backgrounds/"
|
|
USER_BACKGROUNDS_PATH="$HOME/.config/omarchy/backgrounds/$THEME_NAME/"
|
|
CURRENT_BACKGROUND_LINK="$HOME/.local/state/omarchy/current/background"
|
|
|
|
mapfile -d '' -t BACKGROUNDS < <(find -L "$USER_BACKGROUNDS_PATH" "$THEME_BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
|
|
TOTAL=${#BACKGROUNDS[@]}
|
|
|
|
if (( TOTAL == 0 )); then
|
|
notify-send "No background was found for theme" -t 2000
|
|
setsid uwsm app -- awww clear >/dev/null 2>&1 &
|
|
else
|
|
# Get current background from symlink
|
|
if [[ -L $CURRENT_BACKGROUND_LINK ]]; then
|
|
CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
|
|
else
|
|
# Default to first background if no symlink exists
|
|
CURRENT_BACKGROUND=""
|
|
fi
|
|
|
|
# Find current background index
|
|
INDEX=-1
|
|
for i in "${!BACKGROUNDS[@]}"; do
|
|
if [[ ${BACKGROUNDS[$i]} == $CURRENT_BACKGROUND ]]; then
|
|
INDEX=$i
|
|
break
|
|
fi
|
|
done
|
|
|
|
# Get next background (wrap around)
|
|
if (( INDEX == -1 )); then
|
|
# Use the first background when no match was found
|
|
NEW_BACKGROUND="${BACKGROUNDS[0]}"
|
|
else
|
|
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
|
NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
|
|
fi
|
|
|
|
# Set new background symlink
|
|
ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
|
|
|
|
setsid uwsm app -- awww img "$CURRENT_BACKGROUND_LINK" >/dev/null 2>&1 &
|
|
fi
|