Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ Aim for a video between five and seven seconds long that opens on its scene setu

A theme installed from a git repo is held to a much shorter list; see [What an installed theme may not ship](#what-an-installed-theme-may-not-ship).

## Background image variants

A still image can have alternatives in a sibling directory named after the image without its extension:

```text
backgrounds/
01-ink-signature.webp
01-ink-signature/
5120x2160.webp
portrait.png
02-paper-signature.webp
02-paper-signature/
5120x2160.webp
```

The top-level file is both the default image and the design's identity. The existing picker, cycling commands, and current-background symlink continue to refer to that file. Nested alternatives do not add picker entries. Themes therefore work without variant support, using their default images.

The desktop background plugin considers the default plus JPG, JPEG, PNG, WebP, and BMP files immediately inside its matching directory. It reads actual image dimensions; filenames do not declare dimensions. Choose distinct default basenames within a background directory. GIF and video wallpapers retain their existing behavior and do not participate in variant selection.

Each output independently chooses the least-cropped aspect ratio, then the smallest sufficient resolution at that aspect ratio, or the largest available if all would require enlargement. Logical window dimensions multiplied by the window's fractional pixel density account for scaling and rotation. Screen changes reevaluate selection without rescanning images. Metadata is cached under `~/.cache/omarchy/background-dimensions` (or nonempty `$XDG_CACHE_HOME`) by path and a hash of the compressed file contents, so unchanged theme copies reuse dimensions. Changed files replace their cache record; records unused for 30 days are pruned. Cache write failures do not prevent variant selection. Selecting a different background or applying a theme refreshes its candidate list; unreadable alternatives are skipped.

The same convention works for additional user backgrounds. The lock screen and picker previews continue to use the default image. Selecting an alternative file directly displays that file normally unless it also has a matching sibling directory.

Matching intros still use the top-level image's basename in `intros/`; image variants do not select separate intro videos. Intro playback and its outgoing cover use the shared/default artwork, then the desktop returns to each output's selected still variant. If a variant changes the composition, the handoff can visibly change framing.

## Theme activation flow

`omarchy-theme-set <name>` builds a clean staging directory at
Expand Down
2 changes: 2 additions & 0 deletions manual/39-backgrounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ You can do this most easily by going to _Install > Style > Background_ in the Om

Backgrounds can be videos as well as stills. Drop an `mp4`, `m4v`, `mov`, `webm`, `mkv`, or `avi` file in the same folder and it appears alongside the images. Videos are played by the OWE wallpaper engine. It decodes the video once for all monitors and plays its sound through the default audio output, and it stops playback whenever nothing can see it. A video wallpaper still costs far more power than a still one.

A still background can have alternatives for different monitor shapes and resolutions. Keep the default image in the background folder (for example, `design.webp`) and put alternatives directly in a sibling folder named without the extension (`design/`). Only the default appears in the picker; each monitor automatically chooses its best-fitting image. The lock screen continues to use the default. See [Background sizes](43-making-your-own-theme.md#background-sizes) for an example and supported formats.

Themes can include a short intro for a still background. For `backgrounds/road.webp`, the matching video lives at `backgrounds/intros/road.mp4`. It plays automatically at boot, when switching to a theme with that background selected, and when choosing that background, then returns to the still. Intro videos stay out of the background picker and never loop.

Turning off _Appearance > Animations_ also turns off background intros. Omarchy does this by default in a virtual machine. The `omarchy theme bg intro toggle` command can toggle intros separately. Refreshing a theme does not play an intro.
Expand Down
16 changes: 16 additions & 0 deletions manual/43-making-your-own-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ Everything else still works exactly as the theme author wrote it — `btop.theme

Omarchy tells the two apart by whether the theme has its own git repo inside it, which is what `omarchy theme install` leaves behind when it clones. So a theme you wrote stays yours, and one you pulled off the internet stays colours.

### Background sizes

You can provide different sizes or compositions of a background for ordinary, ultrawide, and portrait screens. Keep one default image directly in `backgrounds/`, then put alternatives in a directory with the same name without the file extension:

```text
backgrounds/
01-landscape.webp
01-landscape/
ultrawide.webp
portrait.png
```

Only the default appears in the background picker. Omarchy automatically chooses the image that best fits each monitor's shape and resolution. Alternative filenames are up to you: Omarchy reads the dimensions from the files. JPG, JPEG, PNG, WebP, and BMP alternatives are supported; put them directly inside the matching directory.

The default also supplies the picker preview and lock-screen background, and remains usable on older versions of Omarchy. Themes without alternatives work as before.

### Light mode

If you're making a light mode theme, set `mode = "light"` at the top of your `colors.toml`. Then it'll automatically be paired with light mode for all the apps. (The old way of dropping an empty file called `light.mode` in the root of your theme still works too.)
Expand Down
139 changes: 106 additions & 33 deletions shell/plugins/background/Background.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import QtQuick.Shapes
import qs.Commons
import qs.Commons as Commons
import qs.Ui
import "BackgroundVariants.js" as BackgroundVariants

Item {
id: root
Expand All @@ -20,6 +21,7 @@ Item {

property string currentBackground: ""
property string displayedBackground: ""
property int displayedVersion: 0
property string incomingBackground: ""
property string oldBackground: ""
// A theme switch names its next background before it has staged the rest of
Expand All @@ -40,20 +42,41 @@ Item {
property var sizeQueue: []
property bool finishingTransition: false
property int backgroundVersion: 0
property int reloadVersion: 0
property int revealStartedVersion: -1
property int pendingThemeVersion: -1
property string pendingColorsRaw: ""
property string pendingShellRaw: ""
property real revealProgress: 1
readonly property bool ready: {
if (isVideo(displayedBackground)) return true
if (backgrounds.instances.length === 0) return false
for (var panel of backgrounds.instances) {
// A scan clears busy before onResolved installs its dimensions and paths.
// Keep startup covered until those candidates and every output settle.
if (variantCatalog.busy || resolvedVariantGeneration !== variantCatalog.generation || backgroundPanels.instances.length === 0) return false
for (var panel of backgroundPanels.instances) {
if (!panel.backgroundReady) return false
}
return true
}
property var displayedCandidates: []
property int resolvedVariantGeneration: -1
signal captureBackground()

BackgroundVariantCatalog {
id: variantCatalog
path: root.currentBackground
revision: root.backgroundVersion
onResolved: {
// Variant paths must have a native size before any frame can load them.
var known = Object.assign({}, root.nativeSizes)
for (var i = 0; i < candidates.length; i++) {
var candidate = candidates[i]
known[candidate.path] = { width: candidate.width, height: candidate.height }
}
root.nativeSizes = known
if (!root.incomingBackground) root.displayedCandidates = candidates
root.resolvedVariantGeneration = variantCatalog.generation
}
}

function isVideo(path) {
return Util.isVideoPath(path)
Expand Down Expand Up @@ -98,7 +121,6 @@ Item {
}

function setBackground(path, instant) {
if (instant) reloadVersion += 1
transitionBackground("", path, path, instant, instant)
}

Expand All @@ -107,6 +129,8 @@ Item {
finalPath = String(finalPath || path).trim()
fromPath = String(fromPath || "").trim()
if (!path || (!force && finalPath === currentBackground)) return
// Capture each output's actual variant before theme paths are replaced.
captureBackground()
if (path !== preparedBackground) preparedBackground = ""
preparedBackgroundTimer.stop()
lastTransitionPath = path
Expand All @@ -128,6 +152,8 @@ Item {
oldBackground = ""
incomingBackground = ""
preparedBackground = ""
displayedCandidates = []
displayedVersion = backgroundVersion
displayedBackground = finalPath
revealProgress = 1
return
Expand Down Expand Up @@ -175,6 +201,18 @@ Item {
revealAnimation.restart()
}

function finishTransition() {
if (!finishingTransition) return
for (var i = 0; i < backgroundPanels.instances.length; i++) {
if (!backgroundPanels.instances[i].backgroundReady) return
}
incomingBackground = ""
oldBackground = ""
preparedBackground = ""
finishingTransition = false
pruneNativeSizes()
}

function prepareBackground(path) {
path = String(path || "").trim()
// Only a still that is not already on screen is worth decoding ahead.
Expand Down Expand Up @@ -202,6 +240,7 @@ Item {
function pruneNativeSizes() {
var kept = {}
var paths = [displayedBackground, incomingBackground, oldBackground, preparedBackground]
for (var c = 0; c < displayedCandidates.length; c++) paths.push(displayedCandidates[c].path)
for (var i = 0; i < paths.length; i++) {
if (paths[i] && nativeSizes[paths[i]] !== undefined) kept[paths[i]] = nativeSizes[paths[i]]
}
Expand Down Expand Up @@ -326,18 +365,22 @@ Item {
easing.type: Easing.OutCubic
onFinished: {
if (root.incomingBackground) {
root.displayedCandidates = variantCatalog.candidates
root.displayedVersion = root.backgroundVersion
root.displayedBackground = root.currentBackground || root.incomingBackground
root.finishingTransition = true
}
root.revealProgress = 1
Qt.callLater(root.finishTransition)
}
}

Component.onCompleted: refreshBackground()

Variants {
id: backgrounds
id: backgroundPanels
model: Quickshell.screens
onInstancesChanged: Qt.callLater(root.finishTransition)

PanelWindow {
id: panel
Expand All @@ -361,12 +404,28 @@ Item {
property bool maskReady: false
property int readyFrames: 0
readonly property bool backgroundReady: base.ready && readyFrames >= 2
onBackgroundReadyChanged: if (backgroundReady) Qt.callLater(root.finishTransition)

FrameAnimation {
running: base.ready && panel.readyFrames < 2
onTriggered: panel.readyFrames += 1
}

property var failedVariants: []
// ShellScreen's ratio is rounded up on Wayland; the window follows
// wp_fractional_scale_v1 and reports the actual output scale.
readonly property real pixelScale: panel.devicePixelRatio
readonly property string displayedPath: BackgroundVariants.choose(
root.displayedCandidates.filter(function(candidate) { return panel.failedVariants.indexOf(candidate.path) === -1 }),
root.displayedBackground, width, height, pixelScale)
readonly property string incomingPath: BackgroundVariants.choose(
variantCatalog.candidates.filter(function(candidate) { return panel.failedVariants.indexOf(candidate.path) === -1 }),
root.incomingBackground, width, height, pixelScale)

function rejectVariant(path) {
if (failedVariants.indexOf(path) === -1) failedVariants = failedVariants.concat([path])
}

// Decode the wallpaper at the size this screen can show, not the size
// it was shipped at. With PreserveAspectCrop Qt takes sourceSize as the
// area to cover, so this is the smallest decode that still fills the
Expand All @@ -377,8 +436,8 @@ Item {
// decoded at native size first, and a wallpaper smaller than the screen
// is decoded at its own size rather than scaled up to cover the screen.
readonly property bool sized: width > 0 && height > 0
readonly property int decodeWidth: sized ? Math.ceil(width * screen.devicePixelRatio) : 0
readonly property int decodeHeight: sized ? Math.ceil(height * screen.devicePixelRatio) : 0
readonly property int decodeWidth: sized ? Math.ceil(width * pixelScale) : 0
readonly property int decodeHeight: sized ? Math.ceil(height * pixelScale) : 0

function decodeSize(path) {
if (!sized || !path) return Qt.size(0, 0)
Expand All @@ -390,10 +449,10 @@ Item {

function maybeStartReveal() {
if (!root.incomingBackground || root.revealProgress !== 0 || maskReady) return
if (incomingFrame.status !== Image.Ready) return
if (variantCatalog.busy || incomingFrame.status !== Image.Ready) return
Qt.callLater(function() {
if (!root.incomingBackground || root.revealProgress !== 0 || maskReady) return
if (incomingFrame.status !== Image.Ready) return
if (variantCatalog.busy || incomingFrame.status !== Image.Ready) return
root.startReveal(panel)
})
}
Expand All @@ -408,38 +467,37 @@ Item {
BackgroundMedia {
id: base
anchors.fill: parent
path: root.displayedBackground
version: root.reloadVersion
path: panel.displayedPath
version: root.displayedVersion
// Versioned URLs invalidate replaced files without disabling sharing
// between outputs that use the same path and decode size.
cached: true
constrainDecode: true
decodeSize: panel.decodeSize(root.displayedBackground)
onFailedChanged: if (failed) root.recoverBackground(path)
decodeSize: panel.decodeSize(panel.displayedPath)
onFailedChanged: {
if (!failed) return
var failedPath = path
// Changing the chosen variant synchronously reenters Image.failed.
Qt.callLater(function() {
if (!base.failed || base.path !== failedPath) return
// A broken alternative is local to this output. Only a failed
// default should resolve the shared selection from the state link.
if (failedPath === root.displayedBackground) root.recoverBackground(failedPath)
else panel.rejectVariant(failedPath)
})
}
onReadyChanged: {
panel.readyFrames = 0
if (ready && root.finishingTransition) {
root.incomingBackground = ""
root.oldBackground = ""
root.preparedBackground = ""
root.finishingTransition = false
root.pruneNativeSizes()
}
}
}

Image {
ShaderEffectSource {
id: oldFrame
anchors.fill: parent
readonly property size decode: panel.decodeSize(root.oldBackground)
source: decode.width > 0 ? root.imageUrl(root.oldBackground) : ""
sourceSize.width: decode.width
sourceSize.height: decode.height
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: false
sourceItem: root.oldBackground !== "" ? base : null
live: false
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
smooth: true
mipmap: true
visible: root.oldBackground !== "" && root.revealProgress < 1
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
onStatusChanged: panel.maybeStartReveal()
}

Item {
Expand All @@ -461,16 +519,22 @@ Item {
// The same URL and size as a prepared frame keeps its decoded
// image, so a transition to it can reveal at once.
readonly property string framePath: root.incomingBackground || root.preparedBackground
readonly property size decode: panel.decodeSize(framePath)
source: decode.width > 0 ? root.imageUrl(framePath) : ""
readonly property string resolvedPath: root.incomingBackground && !variantCatalog.busy ? panel.incomingPath : framePath
readonly property size decode: panel.decodeSize(resolvedPath)
// Keep a prepared default decoded while the catalog scans. Only
// maybeStartReveal is gated; a flat background retains its frame.
source: decode.width > 0 ? root.imageUrl(resolvedPath) : ""
sourceSize.width: decode.width
sourceSize.height: decode.height
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: false
smooth: true
mipmap: true
onStatusChanged: panel.maybeStartReveal()
onStatusChanged: {
if (status === Image.Error && root.incomingBackground) panel.rejectVariant(resolvedPath)
panel.maybeStartReveal()
}
}
}

Expand Down Expand Up @@ -504,12 +568,21 @@ Item {

Connections {
target: root
function onCaptureBackground() {
oldFrame.scheduleUpdate()
panel.failedVariants = []
}
function onIncomingBackgroundChanged() {
panel.maskReady = false
panel.maybeStartReveal()
}
}

Connections {
target: variantCatalog
function onResolved() { panel.maybeStartReveal() }
}

DesktopClicks { service: root }
}
}
Expand Down
Loading