Skip to content

Support per-monitor background image variants - #11451

Open
rullopat wants to merge 14 commits into
omacom:quattrofrom
rullopat:background-image-variants
Open

rullopat wants to merge 14 commits into
omacom:quattrofrom
rullopat:background-image-variants

Conversation

@rullopat

@rullopat rullopat commented Sep 12, 2026 •

Copy link
Copy Markdown

Summary

Themes that ship ordinary, ultrawide, and portrait versions of the same artwork currently expose each top-level file as a separate background. This adds automatic per-monitor still-image variants to the built-in background plugin, keeping one picker entry per design.

The picker UI and saved-selection mechanism stay unchanged. Theme authors opt in by keeping a default image at the top level and placing alternatives in a sibling directory named after its basename:

backgrounds/
  01-ink-signature.webp
  01-ink-signature/
    ultrawide.webp
    portrait.png
  02-paper-signature.webp

Alternative filenames are arbitrary; selection uses actual image dimensions, not filename conventions. Themes without these directories continue to work as before.

Selection and compatibility

  • Each monitor chooses the aspect ratio requiring the least cropping, then the smallest sufficient image at that ratio, or the largest available if all are too small.
  • Selection accounts for fractional output scaling and updates when screen geometry or scaling changes.
  • The top-level image remains the picker entry and saved selection, supplies the picker preview and lock-screen background, and remains usable on older installations.
  • Alternatives support JPG, JPEG, PNG, WebP, and BMP, directly inside the matching directory. GIF and video backgrounds keep their existing behavior.
  • Theme-author documentation covers the convention in the theming reference and manual, with a link from the backgrounds page.

Runtime behavior

  • Dimension discovery runs asynchronously; stale results cannot replace a newer background selection. Scans are bounded, and a timed-out scan retains candidates already discovered.
  • Dimension caching recognizes unchanged file contents across theme reapplication. Cache writes are best-effort, and old entries are pruned.
  • Transitions capture each output's rendered variant and retain outgoing frames until replacement frames are ready, including same-path image refreshes.
  • An alternative that fails to load is excluded on the affected output so another candidate can be selected. If the default fails, the plugin re-resolves the saved background link, with a theme-background fallback when the link is dangling.
  • The implementation has been merged with subsequent quattro background changes, including native-size probing and wallpaper recovery.

Feedback requested

This remains a draft for maintainer feedback on the opt-in folder convention and selection policy. The product decision is whether one selectable design with automatic per-monitor variants is the desired model; this does not introduce a new picker interface or per-monitor configuration UI.

Related discussion: #11443

Validation

Automated coverage now includes:

  • Selection policy, fractional scaling, actual image dimensions, cache invalidation and write failures, and keeping alternatives out of picker entries.
  • The asynchronous QML catalog, including stale-result handling and retaining partial results after a timeout.
  • Rendered pixel checks in an isolated Xvfb/OpenGL fixture for landscape and portrait outputs: outgoing-frame capture, reveal masks, delayed replacement readiness, same-path reloads, failed-variant fallback, and default-background recovery.
  • Existing background behavior tests.

Previously recorded validation (not a fresh full-suite run for this description update):

  • Background variant, background, and video-background tests passed.
  • Isolated nested-compositor checks verified ordinary, ultrawide, and portrait outputs; scaling, output reconnection, transitions, and refreshing a variant at the same filename.
  • ./test/all: CLI suite passed; six of 237 shell test files initially failed. config, snapper, and unowned-system-paths passed with the required packaging/installer checkouts; launch-about passed with NO_COLOR unset. The remaining locate and network-qr failures also reproduced on the unchanged base commit in that environment.
  • git diff --check passed.

Full disposable-VM acceptance testing has not been run. The rendered fixture exercises background rendering in isolation; it is not a substitute for real multi-monitor Wayland acceptance testing.

@rullopat
rullopat marked this pull request as ready for review September 12, 2026 13:06
@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@llstrk

llstrk commented Oct 1, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: The PR conflicts with current quattro, which removed the reload mechanism it relies on.

Conflicts with current quattro

git merge-tree against quattro (8b4eae66) conflicts in three files. quattro removed displayedReloads and reloads, and loads an image only once nativeSizes[path] exists, so variant paths would stay blank. Open #9312, #11534 and #10249 propose other per-monitor conventions.

Suggested change: rebase, feed the catalog's dimensions into nativeSizes, and settle one convention.

Reproducer (merge check at 3895f19)

Reviewed head: 3895f19. quattro tip: 8b4eae6 (merge-base 31bd80d).

$ git fetch origin 3895f19d6df5c9f60366123c1402ae24b1351dd2 8b4eae66da2938ba9559f103b18dbf85cdf28a70
$ git merge-tree --write-tree --name-only --messages 8b4eae66da2938ba9559f103b18dbf85cdf28a70 3895f19d6df5c9f60366123c1402ae24b1351dd2
1dc151374f6545498556fe8c7399da90fd379843
shell/Ui/BackgroundMedia.qml
shell/plugins/background/Background.qml
test/shell.d/video-background-test.sh

Auto-merging docs/theming.md
Auto-merging shell/Ui/BackgroundMedia.qml
CONFLICT (content): Merge conflict in shell/Ui/BackgroundMedia.qml
Auto-merging shell/plugins/background/Background.qml
CONFLICT (content): Merge conflict in shell/plugins/background/Background.qml
Auto-merging test/shell.d/video-background-test.sh
CONFLICT (content): Merge conflict in test/shell.d/video-background-test.sh

Exit status 1. Conflict regions in the merged tree: Background.qml 6, BackgroundMedia.qml 2, video-background-test.sh 1.

The parts that merge cleanly still conflict in meaning. The merged Background.qml keeps root.displayedReloads += 1 in the reveal's onFinished, but quattro removed the displayedReloads property. quattro's test/shell.d/video-background-test.sh (lines 77-81 at 8b4eae6) also asserts that neither Background.qml nor BackgroundMedia.qml contains displayedReloads.

Fractional scales pick an oversized file

pixelScale uses ShellScreen.devicePixelRatio, which on Hyprland is ceil(scale). A 2560x1600 output at 1.6 picks 3840x2400 over a sufficient 2560x1600 file. Reproduced with Node, not on a live output.

Suggested change: use the panel window's fractional devicePixelRatio (from source; not tested on a live fractional output).

Reproducer (fails at 3895f19)

Reviewed head: 3895f19. Needs node.

This reproduces the selection that follows from the values the panel passes to choose(). It was not run on a fractionally scaled Hyprland output. The panel passes modelData.width, modelData.height and modelData.devicePixelRatio (Background.qml lines 279-285). Where those values come from:

  • Quickshell 0.3.1 ShellScreen.devicePixelRatio returns QScreen::devicePixelRatio() (src/core/qmlscreen.cpp). Its width and height come from QScreen::size().
  • In Qt 6.11's Wayland plugin, QWaylandScreen::devicePixelRatio() returns the integer wl_output.scale (qreal(mScale)). geometry() returns the xdg-output logical geometry (qwaylandscreen.cpp).
  • Hyprland sends wl_output.scale as std::ceil(m_scale) (src/protocols/core/Output.cpp). The xdg-output logical size is the transformed pixel size divided by the scale (src/output/Monitor.cpp).
  • bin/omarchy-hyprland-monitor-scaling offers 1, 1.25, 1.6, 2, 3 and 4.

On a 2560x1600 panel at scale 1.6, ShellScreen therefore reports 1600x1000 with devicePixelRatio 2. The PR treats that as 3200x2000 physical pixels.

Save as repro-fractional.js in a checkout of the PR head and run ROOT=$PWD node repro-fractional.js:

// Run with test/shell.d/base-test.sh's run_node_test prelude, or plain node with ROOT set.
const path = require('path')
const { choose } = require(path.join(process.env.ROOT, 'shell/plugins/background/BackgroundVariants.js'))
const image = (p, width, height) => ({ path: p, width, height })
const sizes = [image('2560x1600', 2560, 1600), image('3840x2400', 3840, 2400)]
// A 2560x1600 panel at Hyprland scale 1.6 (one of omarchy-hyprland-monitor-scaling's steps).
// Quickshell's ShellScreen reports the xdg-output logical size, 1600x1000, and
// devicePixelRatio 2, because Qt's QWaylandScreen::devicePixelRatio is the
// integer wl_output.scale and Hyprland sends ceil(1.6) = 2.
const chosen = choose(sizes, 'default', 1600, 1000, 2)
console.log('chosen with ShellScreen values (1600x1000, devicePixelRatio 2):', chosen)
console.log('chosen with the output\'s real scale (1600x1000, 1.6):', choose(sizes, 'default', 1600, 1000, 1.6))
if (chosen !== '2560x1600') {
  console.error('not ok - a 2560x1600 output should not need the 3840x2400 file')
  process.exit(1)
}

Output at the reviewed head (exit status 1):

$ ROOT=$PWD node repro-fractional.js
chosen with ShellScreen values (1600x1000, devicePixelRatio 2): 3840x2400
chosen with the output's real scale (1600x1000, 1.6): 2560x1600
not ok - a 2560x1600 output should not need the 3840x2400 file

The panel window's own devicePixelRatio (Quickshell QsWindow.devicePixelRatio, backed by QWaylandWindow::devicePixelRatio(), which follows wp_fractional_scale_v1) carries the fractional value.

More findings

An unwritable cache drops uncached candidates

In variant-images.py, the cache write shares the try with the probe, so any OSError (read-only or full ~/.cache) turns a successful probe into None. Files not already cached are dropped; with nothing cached, as right after a theme apply, every output falls back to the default. Suggested change: wrap the cache write in its own try/except OSError and return the dimensions anyway.

Reviewed head: 3895f19. Needs python and vipsheader (libvips), like test/shell.d/background-variants-test.sh.

dimensions() writes the cache inside the same try that reads the dimensions, so an OSError from cache.mkdir() or the temporary write turns a successful vipsheader probe into None. When ~/.cache is read-only or full, every file whose dimensions are not already cached is dropped, including the default. A cache hit needs no write, so it still returns that file. Right after a theme application nothing is cached, because cp -r changes every ctime.

Save as repro-cache-write.py in a checkout of the PR head and run ROOT=$PWD python repro-cache-write.py. It uses the same helpers as the Python block in background-variants-test.sh:

# Same helpers as the python block in test/shell.d/background-variants-test.sh.
import importlib.util
import os
from pathlib import Path
import struct
import tempfile
import zlib

spec = importlib.util.spec_from_file_location('variants', Path(os.environ['ROOT']) / 'shell/plugins/background/variant-images.py')
variants = importlib.util.module_from_spec(spec)
spec.loader.exec_module(variants)

def png(path, width, height):
  def chunk(name, data):
    return struct.pack('!I', len(data)) + name + data + struct.pack('!I', zlib.crc32(name + data))
  path.write_bytes(b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', struct.pack('!2I5B', width, height, 8, 2, 0, 0, 0))
          + chunk(b'IDAT', zlib.compress((b'\0' + b'\x00\x88\xff' * width) * height)) + chunk(b'IEND', b''))

with tempfile.TemporaryDirectory(prefix='omarchy-variant-test-') as temporary:
  root = Path(temporary)
  default = root / 'design.png'
  png(default, 160, 90)
  (root / 'design').mkdir()
  png(root / 'design' / 'wide.png', 210, 90)
  # A cache location that cannot be created (here: a file where a directory
  # should be; a read-only or full ~/.cache behaves the same way).
  (root / 'blocked').write_text('')
  unwritable_cache = root / 'blocked' / 'cache'
  found = variants.candidates(default, unwritable_cache)
  print('candidates with an unwritable cache:', [{**c, 'path': Path(c['path']).relative_to(root).as_posix()} for c in found])
  if len(found) != 2:
    raise SystemExit('not ok - variants are listed when the dimension cache cannot be written')
  print('ok - variants are listed when the dimension cache cannot be written')

Output at the reviewed head (exit status 1):

$ ROOT=$PWD python repro-cache-write.py
candidates with an unwritable cache: []
not ok - variants are listed when the dimension cache cannot be written

Control: run the same script with (root / 'blocked').write_text('') changed to (root / 'blocked').mkdir(), so the cache is writable. It prints:

candidates with a writable cache: [{'path': 'design.png', 'width': 160, 'height': 90}, {'path': 'design/wide.png', 'width': 210, 'height': 90}]
ok - control: variants are listed with a writable cache

Every theme application misses the dimension cache

The key includes ctime and mtime, and omarchy-theme-set copies the theme with cp -r, so the first scan after each apply re-probes every file and adds cache entries that are never removed. In a sandbox, a three-file design took about 0.27 s uncached against 0.03 s cached, and the incoming frame waits for the scan. Suggested change: probe all files in one vipsheader call (0.040 s against 0.247 s for six calls), or drop ctime from the key and prune old entries.

Reviewed head: 3895f19. Needs python, cp and vipsheader.

The cache key includes the path, size, mtime and ctime. omarchy-theme-set stages a theme with cp -r into next-theme and then mvs it over current/theme. Every file under current/theme/backgrounds/ therefore has a new ctime (and mtime) after each application. The first scan after applying a theme probes every file again, and the old entries are never removed.

Save as repro-theme-reapply.py in a checkout of the PR head and run ROOT=$PWD python repro-theme-reapply.py:

# Same helpers as the python block in test/shell.d/background-variants-test.sh.
import importlib.util
import os
from pathlib import Path
import shutil
import struct
import subprocess
import tempfile
from unittest.mock import patch
import zlib

spec = importlib.util.spec_from_file_location('variants', Path(os.environ['ROOT']) / 'shell/plugins/background/variant-images.py')
variants = importlib.util.module_from_spec(spec)
spec.loader.exec_module(variants)

def png(path, width, height):
  def chunk(name, data):
    return struct.pack('!I', len(data)) + name + data + struct.pack('!I', zlib.crc32(name + data))
  path.write_bytes(b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', struct.pack('!2I5B', width, height, 8, 2, 0, 0, 0))
          + chunk(b'IDAT', zlib.compress((b'\0' + b'\x00\x88\xff' * width) * height)) + chunk(b'IEND', b''))

with tempfile.TemporaryDirectory(prefix='omarchy-variant-test-') as temporary:
  root = Path(temporary)
  theme = root / 'themes' / 'example'
  (theme / 'backgrounds' / '1-design').mkdir(parents=True)
  png(theme / 'backgrounds' / '1-design.png', 160, 90)
  png(theme / 'backgrounds' / '1-design' / 'wide.png', 210, 90)
  current = root / 'current' / 'theme'
  cache = root / 'cache'

  def apply_theme():
    # omarchy-theme-set stages with `cp -r` into next-theme, then
    # `rm -rf current/theme && mv next-theme current/theme`.
    staged = root / 'current' / 'next-theme'
    staged.mkdir(parents=True)
    subprocess.run(['cp', '-r', *[str(p) for p in theme.iterdir()], str(staged)], check=True)
    shutil.rmtree(current, ignore_errors=True)
    staged.rename(current)

  apply_theme()
  variants.candidates(current / 'backgrounds' / '1-design.png', cache)
  print('cache entries after first apply:', len(list(cache.iterdir())))
  apply_theme()
  probes = []
  real_check_output = variants.subprocess.check_output
  def counting(*args, **kwargs):
    probes.append(args[0])
    return real_check_output(*args, **kwargs)
  with patch.object(variants.subprocess, 'check_output', side_effect=counting):
    variants.candidates(current / 'backgrounds' / '1-design.png', cache)
  print('vipsheader calls after re-applying the unchanged theme:', len(probes))
  print('cache entries after second apply:', len(list(cache.iterdir())))
  if probes:
    raise SystemExit('not ok - re-applying an unchanged theme reuses cached dimensions')
  print('ok - re-applying an unchanged theme reuses cached dimensions')

Output at the reviewed head (exit status 1):

$ ROOT=$PWD python repro-theme-reapply.py
cache entries after first apply: 2
vipsheader calls after re-applying the unchanged theme: 4
cache entries after second apply: 4
not ok - re-applying an unchanged theme reuses cached dimensions

Four vipsheader calls means both fields of both files were probed again (the PR makes one call per field per file). The PR's own test, which rescans unchanged files, shows that repeat scans of unchanged files do hit the cache.

Monitors stop sharing one decode after the first reveal

cache: root.version === 0 && root.reloads === 0 turns false once displayedReloads increments at the first reveal end, so each output showing the same file decodes and holds its own full-resolution copy (Qt's pixmap cache shares by URL only when caching is on). Traced from Qt 6.11 source, not measured; applies at this head only, since quattro removed reloads. Suggested change: keep cache: root.version === 0; the &r= query already makes each reload a distinct key.

Details

Verified (sandbox and source, at 3895f19):

  • choose() follows the stated policy for integer scales, rotation and ties, independent of candidate order (24,000 randomised trials).
  • The catalog discards stale scans; the PR's Quickshell fixture fails when the generation check or the stale restart is removed.
  • variant-images.py handles spaces, several dots, upper-case extensions, and invalid or unreadable files.
  • Variants stay out of the picker and bg next; the lock screen keeps the default image.
  • background-variants-test.sh passes, and the full ./test/shell run has the same six environment failures at head and base.

Optional notes:

  • manual/39-backgrounds.md, the main backgrounds page, does not mention the sibling-directory convention or link the new section in manual/43.
  • An empty XDG_CACHE_HOME makes variant-images.py write omarchy/background-dimensions relative to the working directory; os.environ.get(...) or default avoids it.

Review information

Test scope: Source and sandbox tests at 3895f19; not tested on real multi-monitor outputs.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@rullopat
rullopat force-pushed the background-image-variants branch from 3895f19 to 019cd5a Compare October 2, 2026 14:30
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes appear safe to merge; the previously reported delayed-color overwrite is fixed.

Summary

Adds per-monitor still-image variants while keeping one picker entry and saved selection per design.

  • Each monitor can show the best-fitting image for one saved background design.
  • Background changes keep each monitor’s outgoing image until its replacement is ready.

No new actionable issues were found in the changes since the previous review. This review checked code; it did not rerun tests or capture the UI.

Reviews (11) · Last reviewed commit: "Apply a cancelled queued theme's palette..." · Reviewed by Greptile

Comment thread test/shell.d/background-test.sh Resolved
@jandrusk

Copy link
Copy Markdown

Large, well-tested background-variant work. Maintainer product call on scope (new picker model + docs). No blocking notes from a skim of the tests layout.

Comment thread shell/plugins/background/Background.qml Resolved
@rullopat

Copy link
Copy Markdown
Author

Hi @jandrusk, just wanted to add some context to why I created this PR.

I have a widescreen 5K2K monitor and all the backgrounds get cut, so when I created my personal themes I always have 2 background images, one "normal" and one for widescreen, but when you pull out the background selection, you see 2 mostly identical pictures of the same background (that I already don't like) and no easy way to understand which one to select.

rullopat and others added 2 commits November 11, 2026 15:11
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@rullopat

rullopat commented Nov 11, 2026 •

Copy link
Copy Markdown
Author

Merged current quattro again, so this is mergeable. The conflict was in Background.qml, where #17082, #17179 and #17229 reworked the reveal. Variants now sit on top of that: the reveal still waits for every screen, and each monitor keeps its own variant while the last still is held for a video.

Before I keep rebasing, a product call would help. There are four open PRs for backgrounds that fit the monitor, each with a different convention:

Is this something you want in Omarchy, and if so, which shape? I'm happy to rework this one toward whichever convention you prefer, or to close it if another is the direction.

What this one offers:

  • The picker, the saved selection and the background symlink are unchanged. One entry per design.
  • Themes without a variant directory behave exactly as before, and a theme with one still works on older installs through its default image.
  • No filename convention: each monitor takes the least-cropped image, read from the files' real dimensions.
  • Against current quattro it is about 315 lines of runtime code and docs; the rest of the diff is tests.

On video: variants cover stills only. Video wallpapers and intros are OWE's, which decodes one video for all outputs, so they play the same on every monitor. There are two visible seams, both because OWE only knows the default file: an intro ends on the default artwork before a monitor returns to a differently framed variant, and a change from a still to a video shows the default for a few frames before OWE fades the video in. I recorded both on a 5120x2160 output at 60 fps; neither shows a blank or black frame. Both are documented in docs/theming.md, and closing them would need per-output playback in OWE, which is outside this PR.

Comment thread shell/plugins/background/Background.qml Resolved
rullopat and others added 2 commits November 11, 2026 15:19
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A change made mid-reveal restarted it from each output's base, which still
held the image from before that reveal, so the desktop stepped back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Comment thread shell/plugins/background/Background.qml Resolved
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Comment thread shell/plugins/background/Background.qml Resolved
@greptile-apps

greptile-apps Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

Left pending, it could land after a newer theme's colors and replace them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants