diff --git a/Arrange.qml b/Arrange.qml index d000874..e996531 100644 --- a/Arrange.qml +++ b/Arrange.qml @@ -53,8 +53,13 @@ Item { readonly property string configHome: Quickshell.env("XDG_CONFIG_HOME") || (home + "/.config") readonly property string monitorsPath: configHome + "/hypr/monitors.lua" //: Where this plugin was loaded from, for the scripts shipped beside it. - readonly property string pluginDir: manifest && manifest.__sourceDir - ? String(manifest.__sourceDir) : "" + //: Third-party manifests do not carry the host's private `__sourceDir` + //: (Omarchy 4.0.3 sanitizes it), so resolve from this file at the root. + readonly property string pluginDir: { + var url = String(Qt.resolvedUrl(".")) + if (url.indexOf("file://") !== 0) return "" + try { return decodeURIComponent(url.substring(7)).replace(/\/$/, "") } catch (e) { return "" } + } function touch() { revision += 1 } diff --git a/LauncherEntry.qml b/LauncherEntry.qml index ea3e67d..9c6a1d3 100644 --- a/LauncherEntry.qml +++ b/LauncherEntry.qml @@ -17,6 +17,7 @@ QtObject { id: root property var manifest: null + property string pluginDir: "" readonly property string dest: Quickshell.env("HOME") + "/.local/share/applications/displaywright.desktop" @@ -53,7 +54,7 @@ QtObject { // Component.onCompleted, so the paths are built when it arrives rather than // bound -- a binding has not re-evaluated by the time that fires. onManifestChanged: { - var dir = manifest && manifest.__sourceDir + var dir = root.pluginDir if (installed || !dir) return installed = true //: execDetached reports nothing back, so this line is the only evidence @@ -66,11 +67,10 @@ QtObject { Component.onDestruction: { if (!installed) return - var dir = manifest && manifest.__sourceDir //: No folder to test means no way to tell a reload from a removal, and //: keeping the entry is the half that cannot lose one. - if (!dir) return + if (!root.pluginDir) return Quickshell.execDetached(["sh", "-c", removeScript, "sh", - dest, marker, dir + "/manifest.json"]) + dest, marker, root.pluginDir + "/manifest.json"]) } } diff --git a/Wallpaper.qml b/Wallpaper.qml index 0112574..ef8a908 100644 --- a/Wallpaper.qml +++ b/Wallpaper.qml @@ -51,7 +51,7 @@ Item { //: A plain child rather than a typed property: resolving a sibling .qml as //: a property *type* is stricter than instantiating it, and this file is //: the one whose failure takes every wallpaper on the desktop with it. - LauncherEntry { manifest: root.manifest } + LauncherEntry { manifest: root.manifest; pluginDir: root.pluginDir } //: A plain-value snapshot of the shell theme, for the same reason. readonly property var palette: ({ @@ -67,11 +67,16 @@ Item { readonly property string configHome: Quickshell.env("XDG_CONFIG_HOME") || (home + "/.config") readonly property string configPath: configHome + "/displaywright/wallpapers.json" - // Where this plugin was loaded from. The shell stamps it into the manifest; - // hardcoding an install path would break a symlinked checkout and anyone who - // installed by hand somewhere else. - readonly property string pluginDir: manifest && manifest.__sourceDir - ? String(manifest.__sourceDir) : "" + // Where this plugin was loaded from: this file sits at the plugin root, so + // the directory resolves from here. Third-party manifests do not carry the + // host's private `__sourceDir` (Omarchy 4.0.3 sanitizes it), and hardcoding + // an install path would break a symlinked checkout and anyone who installed + // by hand somewhere else. + readonly property string pluginDir: { + var url = String(Qt.resolvedUrl(".")) + if (url.indexOf("file://") !== 0) return "" + try { return decodeURIComponent(url.substring(7)).replace(/\/$/, "") } catch (e) { return "" } + } // ---------------------------------------------------------------- config diff --git a/manifest.json b/manifest.json index 1db0bf8..7f4bf50 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "ai.bkblab.displaywright", "name": "Displaywright", - "version": "0.7.3", + "version": "0.7.4", "author": "bkblab.ai", "license": "MIT", "description": "Per-display wallpapers and a display arrangement editor, inside omarchy-shell. Open it from the Apps menu: SUPER+ALT+SPACE, then type Displays. Or double-click one display's background to give just that display a wallpaper.",