Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion displaywright/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
``omarchy-shell`` plugin that draws it.
"""

__version__ = "0.7.3"
__version__ = "0.7.4"
APP_ID = "ai.bkblab.displaywright"
APP_NAME = "displaywright"

Expand Down
9 changes: 7 additions & 2 deletions plugin/Arrange.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
8 changes: 4 additions & 4 deletions plugin/LauncherEntry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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"])
}
}
29 changes: 22 additions & 7 deletions plugin/Wallpaper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ({
Expand All @@ -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

Expand Down Expand Up @@ -134,6 +139,16 @@ Item {

function reloadConfig() {
if (!root.pluginDir || configReader.running) return
//: The first call comes from onPluginDirChanged, which fires while this
//: object is still being built: the engine evaluates the root's bindings
//: before its children's, so configReader exists but its command binding
//: has not run yet. When pluginDir still arrived late, off the manifest,
//: the same handler ran ahead of the re-evaluation and started the ["true"]
//: placeholder instead -- it collected nothing, and every output sat on
//: the theme background until wallpapers.json was next written
//: (displaywright-shell-plugin#2). Set the command outright, so the read
//: is against the path whichever binding pass got there first.
configReader.command = [root.pluginDir + "/read-config.sh", root.configPath]
configReader.running = true
}

Expand Down Expand Up @@ -203,7 +218,7 @@ Item {
target: "displaywright"

function reload(): string {
configFile.reload()
root.reloadConfig()
root.refreshSpanBox()
return "ok"
}
Expand Down
Binary file modified plugin/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
117 changes: 90 additions & 27 deletions tools/tst_icon.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
//
// make icon
//
// Drawn rather than sourced so there is nothing to lose track of, and kept to
// three shapes because the launcher renders it at 32px as often as 256.
// Drawn rather than sourced so there is nothing to lose track of. The app
// menu shows it at around 24px, so it is one silhouette: two display frames
// standing in front of a dusk wallpaper, each framing its own piece of it.

import QtQuick
import QtTest
Expand All @@ -16,37 +17,99 @@ TestCase {
width: 256
height: 256

Component {
Canvas {
id: art
Rectangle {
width: 256; height: 256
radius: 56
gradient: Gradient {
GradientStop { position: 0.0; color: "#4a90e2" }
GradientStop { position: 1.0; color: "#2b5fa8" }
}

// Two landscape displays side by side and one turned portrait: the
// arrangement is the product, so the icon is an arrangement.
Rectangle {
x: 34; y: 96; width: 92; height: 60; radius: 7
color: "#ffffff"; opacity: 0.95
}
Rectangle {
x: 134; y: 74; width: 88; height: 56; radius: 7
color: "#ffffff"; opacity: 0.72
}
Rectangle {
x: 150; y: 140; width: 44; height: 68; radius: 7
color: "#ffffff"; opacity: 0.45
}
width: 256; height: 256
renderStrategy: Canvas.Immediate
renderTarget: Canvas.Image

function roundRect(ctx, x, y, w, h, r) {
ctx.beginPath()
ctx.moveTo(x + r, y)
ctx.arcTo(x + w, y, x + w, y + h, r)
ctx.arcTo(x + w, y + h, x, y + h, r)
ctx.arcTo(x, y + h, x, y, r)
ctx.arcTo(x, y, x + w, y, r)
ctx.closePath()
}

// A display: glass that lifts the scene behind it, a bright bezel, and a
// stand. Drawn heavy on purpose -- at 24px anything thinner vanishes.
function display(ctx, x, y, w, h) {
ctx.save()
ctx.shadowColor = "rgba(20, 10, 40, 0.45)"
ctx.shadowBlur = 18
ctx.shadowOffsetY = 8
roundRect(ctx, x, y, w, h, 12)
ctx.fillStyle = "rgba(255, 255, 255, 0.2)"
ctx.fill()
ctx.restore()

roundRect(ctx, x, y, w, h, 12)
ctx.lineWidth = 11
ctx.strokeStyle = "#fff8f0"
ctx.stroke()

// stand
var cx = x + w / 2
roundRect(ctx, cx - 5, y + h + 4, 10, 14, 4)
ctx.fillStyle = "#fff8f0"
ctx.fill()
roundRect(ctx, cx - 22, y + h + 16, 44, 9, 4.5)
ctx.fill()
}

onPaint: {
var ctx = getContext("2d")
ctx.reset()
ctx.clearRect(0, 0, width, height)

// The plate, and everything after it clipped to it.
roundRect(ctx, 0, 0, 256, 256, 58)
ctx.clip()

// The wallpaper: night at the top down to a warm horizon.
var sky = ctx.createLinearGradient(0, 0, 0, 256)
sky.addColorStop(0.00, "#1b1f5e")
sky.addColorStop(0.45, "#6a3fb5")
sky.addColorStop(0.72, "#e9647a")
sky.addColorStop(1.00, "#ffb05a")
ctx.fillStyle = sky
ctx.fillRect(0, 0, 256, 256)

// The sun, framed by the wide display, with its glow.
var glow = ctx.createRadialGradient(96, 122, 10, 96, 122, 70)
glow.addColorStop(0, "rgba(255, 225, 150, 0.5)")
glow.addColorStop(1, "rgba(255, 225, 150, 0)")
ctx.fillStyle = glow
ctx.fillRect(0, 0, 256, 256)
ctx.beginPath()
ctx.arc(96, 122, 24, 0, Math.PI * 2)
ctx.fillStyle = "#ffe08a"
ctx.fill()

// Hills along the bottom.
ctx.fillStyle = "#2a1a4a"
ctx.beginPath()
ctx.moveTo(0, 256)
ctx.lineTo(0, 212)
ctx.bezierCurveTo(50, 190, 110, 228, 168, 200)
ctx.bezierCurveTo(200, 184, 232, 196, 256, 214)
ctx.lineTo(256, 256)
ctx.closePath()
ctx.fill()

// Two displays: one landscape, one turned portrait. The arrangement is
// the product, so the icon is an arrangement.
display(ctx, 30, 76, 124, 84)
display(ctx, 170, 52, 58, 108)
}
}

function test_shoot() {
const item = art.createObject(suite)
art.requestPaint()
wait(300)
const shot = grabImage(item)
const shot = grabImage(art)
shot.save(String(Qt.resolvedUrl("../plugin/icon.png")).replace("file://", ""))
verify(true)
}
Expand Down
Loading