Fix `omarchy theme bg next` never advancing past the first wallpaper
Read /usr/bin/omarchy-theme-bg-next, -bg-set, -bg-current, -bg-cache, -bg-switcher and /usr/bin/omarchy-theme-set on this workstation at omarchy 4.0.2-1, and fetched bin/omarchy-theme-bg-next and the quattro file tree from omacom/omarchy. Every mechanical claim held. omarchy-theme-bg-set line 12 is still BACKGROUND="$(realpath "$1")", omarchy-theme-bg-next still builds its list with find -L over ~/.config/omarchy/backgrounds/$THEME_NAME/ and ~/.local/state/omarchy/current/theme/backgrounds/ and still compares against a bare readlink, and choose_theme_background in omarchy-theme-set repeats it. I confirmed the asymmetry directly in a scratch directory under /tmp, with no omarchy command run: find -L printed the walked path and realpath printed the resolved one, both for a symlinked directory and for a symlinked file inside a real directory, so the defect is wider than the record said and the cause now covers both. I confirmed on this machine that the stock case is safe, because realpath of ~/.local/state/omarchy/current/theme/backgrounds/1-the-backwater.jpg equals the path find prints and equals the current readlink of the state symlink. I also checked the sort order, since sort -z puts ~/.config paths before ~/.local ones in both en_US.UTF-8 and LC_ALL=C, which is what makes entry 0 always a user background and the symptom a stuck file rather than an alternation. Issue 8594 supports the record almost verbatim, including the suggested patch, and issue 8508 supports the missing prev command, whose only comment points at unmerged pull requests. Corrections: the record said "you cannot step backwards", but omarchy-theme-bg-switcher and omarchy-theme-bg-set <path> both reach any wallpaper, so only the keybinding cycle is one-way. Paths are moved to the installed 4.0.2-1 form, the cp in the workaround gains -L so it cannot recreate the bug, and the danger names the symlink that sed -i would replace. Not exercised: no background command was run on this workstation, by instruction, so the end-to-end cycle was not reproduced here. Severity stays low and frequency stays occasional, since this needs a symlinked user background directory and loses no data.
/usr/bin/omarchy-theme-bg-next and /usr/bin/omarchy-theme-set are owned by the omarchy package, so a manual patch is reverted by the next omarchy update. /usr/share/omarchy/bin/omarchy-theme-bg-next is a symlink to the /usr/bin file, and sed -i without --follow-symlinks replaces that symlink with a regular file, which leaves two divergent copies of the script on disk.
Symptom
omarchy theme bg next sets the first wallpaper and then does nothing on every subsequent press. omarchy theme bg current reports the same file every time. Only happens when ~/.config/omarchy/backgrounds/<theme>/ is a symlink into a dotfiles repo (stow, chezmoi).
Cause
A path-canonicalisation mismatch between two scripts, both confirmed unchanged in omarchy 4.0.2-1 and on the quattro branch. /usr/bin/omarchy-theme-bg-set line 12 stores the chosen background as BACKGROUND="$(realpath "$1")", so the state symlink ~/.local/state/omarchy/current/background points at the resolved path, such as /home/u/dotfiles/walls/foo.jpg. /usr/bin/omarchy-theme-bg-next builds its candidate list with find -L "$HOME/.config/omarchy/backgrounds/$THEME_NAME/" ..., which prints the path it walked rather than the resolved one, then string-compares each entry against a plain readlink of that state symlink. The strings never match, INDEX stays -1, and the script falls through to BACKGROUNDS[0] on every press.
The list is sort -zed as one set and ~/.config sorts before ~/.local, so entry 0 is always a user background whenever that directory holds images. That is why the result is the same file every time rather than an alternation between two.
The same mismatch appears when the directory is real but the image files inside it are symlinks, which is what stow leaves when the tree is not folded. Stock theme backgrounds are unaffected because ~/.local/state/omarchy/current/theme/backgrounds/ is a real copied directory, so realpath of a stock background equals the path find prints and the lookup succeeds. choose_theme_background in /usr/bin/omarchy-theme-set has the identical comparison and the identical defect. There is no omarchy-theme-bg-prev on 4.0.2-1 or on quattro, so stepping backwards means picking a wallpaper directly.
Fix
Simplest workaround, use a real directory instead of a symlink. rm removes only the link, not the dotfiles it points at:
rm ~/.config/omarchy/backgrounds/<theme>
mkdir -p ~/.config/omarchy/backgrounds/<theme>
cp -L ~/dotfiles/walls/* ~/.config/omarchy/backgrounds/<theme>/
-L matters when the source entries are themselves symlinks, because copying a symlink reproduces the bug inside the new directory.
Or patch the comparison to canonicalise both sides. The file to edit is /usr/bin/omarchy-theme-bg-next. /usr/share/omarchy/bin/omarchy-theme-bg-next is only a symlink to it. Change the current-background read and the loop comparison to:
CURRENT_BACKGROUND=$(readlink -f "$CURRENT_BACKGROUND_LINK")
...
if [[ $(realpath "${BACKGROUNDS[$i]}") == "$CURRENT_BACKGROUND" ]]; then
The same change applies to choose_theme_background in /usr/bin/omarchy-theme-set.
There is no prev command, so to reach a specific wallpaper pick it directly:
omarchy-theme-bg-switcher # image picker, any wallpaper for this theme
omarchy-theme-bg-set ~/dotfiles/walls/foo.jpg # explicit path
Verify
Pressing the background-next binding four times cycles a.jpg -> b.jpg -> c.jpg -> a.jpg, and omarchy theme bg current changes on each press.