Skip to content

Build your personal knowledge base with Trilium Notes

docs(desktop): add a reference preview of the assembled DMG window

Elian Doran668646708591
diff --git a/apps/desktop/electron-forge/dmg-background/README.md b/apps/desktop/electron-forge/dmg-background/README.md
index 7f6b8b847e..60c1d2f69d 100644
--- a/apps/desktop/electron-forge/dmg-background/README.md
+++ b/apps/desktop/electron-forge/dmg-background/README.md
@@ -15,6 +15,11 @@ built and visually verified on macOS** (`appdmg` is `os: [darwin]` and isn't ins
`contents` icon coordinates in `forge.config.ts` are a best effort matched to the artwork; fine-tune
them on a real macOS build.
+`preview.png` shows the assembled window with the real app icon and a stand-in Applications folder
+composited at those coordinates. It is **reference only** — appdmg never uses it (it only reads
+`background.png`/`@2x`). Kept reproducible from source so it isn't a mystery image; regenerate with
+`pnpm --filter desktop generate-dmg-preview`.
+
## How it differs from the Windows splash
- **Static, not animated.** A DMG background is a Finder window background image — it can't animate.
diff --git a/apps/desktop/electron-forge/dmg-background/preview.mjs b/apps/desktop/electron-forge/dmg-background/preview.mjs
new file mode 100644
index 0000000000..70ea94ce3f
--- /dev/null
+++ b/apps/desktop/electron-forge/dmg-background/preview.mjs
@@ -0,0 +1,56 @@
+/**
+ * Renders preview.png — an illustration of the assembled DMG window, compositing the
+ * real app icon and a stand-in Applications folder onto background.png at the same
+ * `contents` coordinates used in forge.config.ts.
+ *
+ * This is documentation only: appdmg never sees it (it uses background.png/@2x). It
+ * exists so the "what the DMG looks like" reference is reproducible from source rather
+ * than a mystery committed image. Regenerate with: pnpm --filter desktop generate-dmg-preview
+ */
+import { unlinkSync, writeFileSync } from "fs";
+import { tmpdir } from "os";
+import path from "path";
+import { fileURLToPath, pathToFileURL } from "url";
+
+import { chromium } from "@playwright/test";
+
+const DMG_DIR = path.dirname(fileURLToPath(import.meta.url));
+const WIDTH = 640;
+const HEIGHT = 400;
+const ICON = 128;
+
+// Icon CENTERS (top-left origin here) matching forge.config's bottom-left contents:
+// app (180, 185 from bottom) -> 215 from top; same for Applications at x = 460.
+const bg = pathToFileURL(path.join(DMG_DIR, "background.png")).href;
+const appIcon = pathToFileURL(path.join(DMG_DIR, "..", "app-icon", "mac", "128x128.png")).href;
+const at = (cx) => `left:${cx - ICON / 2}px;top:${215 - ICON / 2}px;width:${ICON}px;height:${ICON}px`;
+
+const folder = `<svg viewBox="0 0 116 92" width="112" height="89">
+ <defs>
+ <linearGradient id="fb" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#57a7e8"/><stop offset="1" stop-color="#3f8ed6"/></linearGradient>
+ <linearGradient id="ff" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#8fcbf5"/><stop offset="1" stop-color="#63b0ee"/></linearGradient>
+ </defs>
+ <path fill="url(#fb)" d="M12 8 h32 l8 8 h52 a12 12 0 0 1 12 12 v52 a12 12 0 0 1 -12 12 H12 a12 12 0 0 1 -12 -12 V20 a12 12 0 0 1 12 -12 z"/>
+ <path fill="url(#ff)" d="M0 36 h116 v44 a12 12 0 0 1 -12 12 H12 a12 12 0 0 1 -12 -12 z"/>
+</svg>`;
+
+const html = `<body style="margin:0"><div style="position:relative;width:${WIDTH}px;height:${HEIGHT}px">
+ <img src="${bg}" style="position:absolute;inset:0;width:${WIDTH}px;height:${HEIGHT}px">
+ <img src="${appIcon}" style="position:absolute;${at(180)}">
+ <div style="position:absolute;${at(460)};display:flex;align-items:center;justify-content:center">${folder}</div>
+</div></body>`;
+
+const tmpHtml = path.join(tmpdir(), "trilium-dmg-preview.html");
+writeFileSync(tmpHtml, html);
+
+const browser = await chromium.launch();
+try {
+ const page = await browser.newPage({ viewport: { width: WIDTH, height: HEIGHT }, deviceScaleFactor: 2 });
+ await page.goto(pathToFileURL(tmpHtml).href);
+ const outputPath = path.join(DMG_DIR, "preview.png");
+ await page.screenshot({ path: outputPath, clip: { x: 0, y: 0, width: WIDTH, height: HEIGHT } });
+ console.log(outputPath);
+} finally {
+ await browser.close();
+ unlinkSync(tmpHtml);
+}
diff --git a/apps/desktop/electron-forge/dmg-background/preview.png b/apps/desktop/electron-forge/dmg-background/preview.png
new file mode 100644
index 0000000000..50a5003d5b
Binary files /dev/null and b/apps/desktop/electron-forge/dmg-background/preview.png differ
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index de5c5818ce..896401052e 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -23,6 +23,7 @@
"e2e": "pnpm build && cross-env TRILIUM_INTEGRATION_TEST=memory-no-store TRILIUM_PORT=8082 TRILIUM_DATA_DIR=data-e2e TRILIUM_ELECTRON_DATA_DIR=data-e2e-electron-8082 ELECTRON_IS_DEV=0 playwright test",
"generate-setup-banners": "tsx electron-forge/setup-icon/generate/generate.mts",
"generate-dmg-background": "tsx electron-forge/dmg-background/generate.mts",
+ "generate-dmg-preview": "tsx electron-forge/dmg-background/preview.mjs",
"test": "vitest --config vitest.config.mts"
},
"dependencies": {