omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Cloned bar plugin never loads: required properties are assigned after instantiation

Open skuthus opened this issue 3 months ago • 1 comments

A bar cloned with omarchy plugin clone omarchy.bar never loads. The bar disappears entirely and does not fall back to the built-in bar.

This makes the documented customization path for the bar unusable — the same one plugins.md and omarchy plugin clone --help point users at.

Steps to reproduce

omarchy plugin clone omarchy.bar   # clones and switches to <user>.bar
omarchy restart shell

No edits to the clone are needed. The bar surface is gone (hyprctl layers shows no omarchy-bar layer), and the shell logs:

WARN scene: file:///home/.../plugins/<user>.bar/Bar.qml[15:3]: Required property omarchyPath was not initialized
WARN scene: file:///home/.../plugins/<user>.bar/Bar.qml[17:3]: Required property barWidgetRegistry was not initialized
WARN scene: file:///home/.../plugins/<user>.bar/Bar.qml[22:3]: Required property barConfig was not initialized
WARN scene: @shell.qml[256:-1]: ReferenceError: errorString is not defined

Expected: the cloned bar loads and behaves identically to the built-in one, since its contents are a byte-for-byte copy.

Cause

Two separate issues, both in shell/shell.qml.

1. Plugin bars receive their required properties after instantiation.

The built-in bar is built from an inline Component that sets them declaratively, which satisfies required (shell.qml:225-234):

Component {
  id: defaultBarComponent
  Bar {
    omarchyPath: shell.omarchyPath
    barWidgetRegistry: shell.barWidgetRegistry
    barConfig: shell.barConfig
    ...
  }
}

A plugin bar instead loads by URL and is configured from onLoaded (shell.qml:246-252):

Loader {
  id: pluginBarLoader
  source: shell.activeBarId !== shell.defaultBarId ? shell.activeBarSourceUrl : ""
  asynchronous: true
  onLoaded: shell.configureBar(item, shell.activeBarManifest)
  ...
}

configureBar() (shell.qml:214-223) assigns omarchyPath, barWidgetRegistry and barConfig — but QML enforces required property at construction, so the object is never created and onLoaded never runs. Since shell/plugins/bar/Bar.qml declares all three as required (lines 15, 17, 22), any faithful clone of it hits this. Any third-party bar copying the built-in bar's structure would too.

A Loader can supply initial properties, which would fix this without changing the packaged Bar.qml:

pluginBarLoader.setSource(url, {
  omarchyPath: shell.omarchyPath,
  barWidgetRegistry: shell.barWidgetRegistry,
  barConfig: shell.barConfig,
  shell: shell,
  manifest: shell.activeBarManifest
})

2. The fallback to the built-in bar throws before it can run.

Loader has no errorString in Qt 6 QML — it is a member of QQmlComponent, which is why the comp.errorString() calls at shell.qml:297, 801 and 804 are fine. The bare call at shell.qml:256 is not:

var detail = errorString && errorString() ? errorString() : ""

The errorString && guard does not help: referencing an undefined identifier raises ReferenceError rather than evaluating to undefined. The exception escapes before shell.failedBarId = shell.activeBarId runs, so the designed fallback to omarchy.bar never happens and the user is left with no bar at all rather than a degraded one.

shell.qml:645 has the same bare call, with a comment stating that Loader.errorString() reflects the source-load failure, so the same fix likely applies there. Line 646 already falls back to sourceComponent.errorString(), which is the correct API.

Worth noting that issue 2 is what turns issue 1 into a blank desktop. With the fallback working, a broken bar plugin would degrade to the built-in bar instead.

Workaround

Change the three root-level required property declarations in the clone's Bar.qml to plain properties with defaults:

property string omarchyPath: ""
property var barWidgetRegistry: null
property var barConfig: null

The delegate-scoped required property var modelData/entry declarations further down the file are fine and should be left alone. configureBar() assigns the real values immediately on load and everything downstream reads them through bindings, so nothing else needs changing.

System details

Omarchy 4.0.0-1 (omarchy 4.0.0-1, omarchy-settings 4.0.0-1)
CPU Intel Core i5-7Y57
GPU Intel HD Graphics 615 (Kaby Lake-Y GT2)
Kernel 7.1.8-arch1-3
qt6-base 6.11.1-1
quickshell-git 0.3.0.r20.g28771c7-1
hyprland 0.56.2-1

Upgraded from 3.8.5 via omarchy-upgrade-to-quattro. Reproduced on a clean clone with no modifications; the hardware looks incidental, since both causes are in QML control flow.

No screenshot attached — the visual symptom is simply an absent bar, and the log plus the two code paths above characterise it more precisely than an image of an empty desktop would.

skuthus avatar Aug 15 '26 05:08 skuthus

Duplicate of #6915 — same root cause: Bar.qml declares omarchyPath, barWidgetRegistry and barConfig as required, but pluginBarLoader sets source with no initial properties and configures them from onLoaded, which never runs because construction already failed.

Consolidating on #6915. Your analysis is the most accurate of the three reports, and two things from it are being carried into the fix there:

  • errorString is a QQmlComponent member, so the bare call in the loader's onStatusChanged throws a ReferenceError and kills the fallback before it can run. The && guard cannot help against an undefined identifier.
  • You are the only reporter to spot the same defect at shell.qml:645, where the correct sourceComponent.errorString() fallback on the next line is unreachable.

Your workaround (demoting the three required declarations in the clone) does work, but it masks the host-side bug rather than fixing it.

— 🤖 Claude, posting on behalf of @dhh

dhh avatar Aug 15 '26 09:08 dhh