Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(desktop): branded macOS DMG background
Elian Doran5faa64675d69
diff --git a/apps/desktop/electron-forge/dmg-background/README.md b/apps/desktop/electron-forge/dmg-background/README.mdnew file mode 100644index 0000000000..7f6b8b847e--- /dev/null+++ b/apps/desktop/electron-forge/dmg-background/README.md@@ -0,0 +1,39 @@+# macOS DMG background++`background.png` / `[email protected]` (and the `-dev` nightly pair) are the Finder-window background+of the mounted `.dmg` — the *drag the app into Applications* screen. Wired into the `@electron-forge/maker-dmg`+config in `electron-forge/forge.config.ts` (`background` + `contents` + `window`).++Generated from `background.html`; don't edit the PNGs by hand. Change the HTML and regenerate:++```bash+pnpm --filter desktop generate-dmg-background+```++Runs on any OS (headless Chromium via the repo's `@playwright/test`) — **but the DMG itself can only be+built and visually verified on macOS** (`appdmg` is `os: [darwin]` and isn't installed elsewhere). The+`contents` icon coordinates in `forge.config.ts` are a best effort matched to the artwork; fine-tune+them on a real macOS build.++## How it differs from the Windows splash++- **Static, not animated.** A DMG background is a Finder window background image — it can't animate.+- **PNG + `@2x` for Retina.** appdmg auto-packages `background.png` and `[email protected]` into a+ multi-resolution TIFF. Finder *is* Retina-aware (unlike Squirrel's loading window), so it renders crisp.+- **One image per channel, not per theme.** Like the splash, the background is baked and doesn't follow+ Finder's light/dark mode — but as a full dark surface it reads fine either way.++## Design++- Reuses the installer splash's brand language: the same dark surface, a soft glow, and a drag arrow+ tinted from the trillium's three leaves (green/orange/red — purple for nightly).+- The two subtle "platforms" mark where Finder drops the real icons (app on the left, `/Applications`+ alias on the right). The icon **centers** must line up with the `contents` coordinates in+ `forge.config.ts`; those use a **bottom-left** origin, so `y_bottomleft = windowHeight - y_fromTop`.+- No icon text labels are baked in — Finder draws the app name and "Applications" under the real icons.++## Output contract++- 640 × 400 pt window; `background.png` is 640 × 400, `[email protected]` is 1280 × 800.+- `iconSize` 128; app icon centered at (180, 185), Applications at (460, 185) in bottom-left coords —+ keep these in sync with the platform positions in `background.html` and the `contents` in the maker config.diff --git a/apps/desktop/electron-forge/dmg-background/background-dev.png b/apps/desktop/electron-forge/dmg-background/background-dev.pngnew file mode 100644index 0000000000..4571ab3d40Binary files /dev/null and b/apps/desktop/electron-forge/dmg-background/background-dev.png differdiff --git a/apps/desktop/electron-forge/dmg-background/[email protected] b/apps/desktop/electron-forge/dmg-background/[email protected]new file mode 100644index 0000000000..6c03c8db80Binary files /dev/null and b/apps/desktop/electron-forge/dmg-background/[email protected] differdiff --git a/apps/desktop/electron-forge/dmg-background/background.html b/apps/desktop/electron-forge/dmg-background/background.htmlnew file mode 100644index 0000000000..ddc88143a4--- /dev/null+++ b/apps/desktop/electron-forge/dmg-background/background.html@@ -0,0 +1,128 @@+<!DOCTYPE html>+<html>+<head>+<meta charset="utf-8">+<title>Trilium DMG background</title>+<style>+ html, body { margin: 0; padding: 0; }+ /* 640 x 400 pt window. Real app icon + /Applications alias are placed on top by+ Finder (via `contents` coords in forge.config), centered on the two platforms;+ Finder also draws their text labels, so none are baked in here. Brand language+ reused from the installer splash: the same dark surface, plus a soft glow and a+ drag arrow tinted from the trillium's leaves. ?variant=nightly swaps to purple. */+ .bg {+ position: relative;+ width: 640px;+ height: 400px;+ overflow: hidden;+ font-family: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;+ color: #f2f3f5;+ }+ .variant-stable {+ background:+ radial-gradient(120px 90px at 34% 30%, rgba(228, 123, 25, 0.16), transparent 70%),+ radial-gradient(140px 100px at 63% 24%, rgba(79, 165, 43, 0.16), transparent 70%),+ radial-gradient(120px 100px at 50% 46%, rgba(227, 63, 59, 0.13), transparent 70%),+ linear-gradient(180deg, #2b3038 0%, #23262b 100%);+ }+ .variant-nightly {+ background:+ radial-gradient(120px 90px at 34% 30%, rgba(177, 138, 214, 0.16), transparent 70%),+ radial-gradient(140px 100px at 63% 24%, rgba(129, 70, 184, 0.18), transparent 70%),+ radial-gradient(120px 100px at 50% 46%, rgba(110, 46, 168, 0.15), transparent 70%),+ linear-gradient(180deg, #2b3038 0%, #23262b 100%);+ }++ .brand {+ position: absolute;+ top: 40px; left: 0; right: 0;+ display: flex; align-items: center; justify-content: center; gap: 13px;+ }+ .brand svg { width: 44px; height: 44px; display: block; }+ .brand .word { font-size: 25px; font-weight: 600; letter-spacing: 0.01em; }+ .brand .word .notes { font-weight: 350; color: #9aa0a8; }+ .brand .badge {+ display: none;+ font-size: 11px; font-weight: 700; letter-spacing: 0.14em;+ color: #ffffff; background: #8146b8; border-radius: 3px; padding: 2px 7px 3px;+ transform: translateY(-2px);+ }+ .variant-nightly .badge { display: inline-block; }++ /* Drop platforms — subtle pedestals under where the real icons land. */+ .platform {+ position: absolute;+ width: 150px; height: 150px;+ top: 140px;+ border-radius: 26px;+ background: rgba(255, 255, 255, 0.035);+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);+ }+ .platform.app { left: 105px; }+ .platform.apps { left: 385px; }++ .arrow { position: absolute; top: 192px; left: 274px; width: 92px; height: 46px; }+ .variant-stable .s0 { stop-color: #e47b19; }+ .variant-stable .s1 { stop-color: #4fa52b; }+ .variant-stable .s2 { stop-color: #e33f3b; }+ .variant-nightly .s0 { stop-color: #b18ad6; }+ .variant-nightly .s1 { stop-color: #8146b8; }+ .variant-nightly .s2 { stop-color: #6e2ea8; }++ .hint {+ position: absolute;+ bottom: 26px; left: 0; right: 0;+ text-align: center;+ font-size: 12.5px; letter-spacing: 0.02em;+ color: #8a909a;+ }++ /* Leaf fills — stable are the exact nine from icon-color.svg; nightly are purple ramps. */+ .variant-stable .g1 { fill: #95c980; } .variant-stable .g2 { fill: #72b755; } .variant-stable .g3 { fill: #4fa52b; }+ .variant-stable .r1 { fill: #ee8c89; } .variant-stable .r2 { fill: #e96562; } .variant-stable .r3 { fill: #e33f3b; }+ .variant-stable .o1 { fill: #efb075; } .variant-stable .o2 { fill: #e99547; } .variant-stable .o3 { fill: #e47b19; }+ .variant-nightly .g1 { fill: #b18ad6; } .variant-nightly .g2 { fill: #9159c4; } .variant-nightly .g3 { fill: #6e2ea8; }+ .variant-nightly .r1 { fill: #cdb2e4; } .variant-nightly .r2 { fill: #b08fd6; } .variant-nightly .r3 { fill: #9668c2; }+ .variant-nightly .o1 { fill: #c09fe0; } .variant-nightly .o2 { fill: #a276cf; } .variant-nightly .o3 { fill: #8146b8; }+</style>+</head>+<body>+<div class="bg" id="bg">+ <div class="brand">+ <svg viewBox="0 0 256 256" aria-hidden="true">+ <path class="g1" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>+ <path class="g2" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>+ <path class="g3" d="m220.5 96.2c-21.1 8.6-46.6 5.3-63.7-0.2l49.2-39.4-51.2 35.9c0.3-15.8 3.5-36.6 14.3-52.8 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.8 66z"/>+ <path class="o1" d="m86.3 59.1c21.7 10.9 32.4 36.6 35.8 54.9l-15.2-6.6-14.5-6.3-50.6-22 48.8 24.9 13.6 6.9 14.3 7.3c-16.6 7.9-41.3 14.5-62.1 4.1-1.8-0.9-3.6-1.9-5.4-3.2-2.3-1.5-4.5-3.2-6.8-5.1-19.9-16.4-40.3-46.4-42.7-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.2 0.8 6.2 1.6 9.1 2.5 4 1.3 7.6 2.8 10.9 4.4z"/>+ <path class="o2" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>+ <path class="o3" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>+ <path class="r1" d="m106.7 179c-5.8-21 5.2-43.8 15.5-57.2l4.8 14.2 4.5 13.4 15.9 47-12.8-47.6-3.6-13.2-3.7-13.9c15.5 6.2 35.1 18.6 40.7 38.8 0.5 1.7 0.9 3.6 1.2 5.5 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.1-3.8-7.6-1.6-3.5-2.9-6.8-3.8-10z"/>+ <path class="r2" d="m110.4 188.9c-3.4-19.8 6.9-40.5 16.6-52.9l4.5 13.4 15.9 47-12.8-47.6-3.6-13.2c13.3 5.2 29.9 15 38.1 30.4 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.2-3.8-7.7z"/>+ <path class="r3" d="m114.2 196.5c-0.7-18 8.6-35.9 17.3-47.1l15.9 47-12.8-47.6c11.6 4.4 26.1 12.4 35.2 24.8 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8z"/>+ </svg>+ <span class="word">Trilium <span class="notes">Notes</span><span class="badge">NIGHTLY</span></span>+ </div>++ <div class="platform app"></div>+ <div class="platform apps"></div>++ <svg class="arrow" viewBox="0 0 92 46" aria-hidden="true">+ <defs>+ <linearGradient id="tri" x1="0" y1="0" x2="1" y2="0">+ <stop class="s0" offset="0"/>+ <stop class="s1" offset="0.5"/>+ <stop class="s2" offset="1"/>+ </linearGradient>+ </defs>+ <path d="M6 23 H74 M56 7 L80 23 L56 39" fill="none" stroke="url(#tri)"+ stroke-width="6" stroke-linecap="round" stroke-linejoin="round"/>+ </svg>++ <div class="hint">Drag Trilium Notes to your Applications folder</div>+</div>+<script>+ const params = new URLSearchParams(location.search);+ document.getElementById("bg").classList.add(params.get("variant") === "nightly" ? "variant-nightly" : "variant-stable");+</script>+</body>+</html>diff --git a/apps/desktop/electron-forge/dmg-background/background.png b/apps/desktop/electron-forge/dmg-background/background.pngnew file mode 100644index 0000000000..892b3eae0dBinary files /dev/null and b/apps/desktop/electron-forge/dmg-background/background.png differdiff --git a/apps/desktop/electron-forge/dmg-background/[email protected] b/apps/desktop/electron-forge/dmg-background/[email protected]new file mode 100644index 0000000000..77824be24aBinary files /dev/null and b/apps/desktop/electron-forge/dmg-background/[email protected] differdiff --git a/apps/desktop/electron-forge/dmg-background/generate.mts b/apps/desktop/electron-forge/dmg-background/generate.mtsnew file mode 100644index 0000000000..82ad18459b--- /dev/null+++ b/apps/desktop/electron-forge/dmg-background/generate.mts@@ -0,0 +1,53 @@+/**+ * Regenerates the macOS DMG background (background.png + [email protected]) from+ * background.html.+ *+ * Run with: pnpm --filter desktop generate-dmg-background+ *+ * The DMG "picture" is the static Finder-window background of the mounted disk+ * image (the app-icon → drag → Applications layout). Unlike the Windows splash it+ * cannot animate, but Finder IS Retina-aware: appdmg auto-packages background.png+ * and its @2x sibling into a multi-resolution TIFF, so a HiDPI Mac renders it crisp.+ *+ * Both files are rendered here with headless Chromium (the repo's @playwright/test),+ * so it runs on any OS — even though the DMG itself can only be BUILT on macOS.+ */+import { chromium } from "@playwright/test";+import path from "path";+import { fileURLToPath, pathToFileURL } from "url";++const DMG_DIR = path.dirname(fileURLToPath(import.meta.url));+const SOURCE = pathToFileURL(path.join(DMG_DIR, "background.html"));++// Window content size in points; must match the `window.size` in forge.config.ts.+const WIDTH = 640;+const HEIGHT = 400;++// One background per channel (stable green / nightly purple), each at 1x and 2x.+const VARIANTS = [+ { variant: "stable", baseName: "background" },+ { variant: "nightly", baseName: "background-dev" }+];+const RESOLUTIONS = [+ { suffix: "", scale: 1 },+ { suffix: "@2x", scale: 2 }+];++const browser = await chromium.launch();+try {+ for (const { variant, baseName } of VARIANTS) {+ for (const { suffix, scale } of RESOLUTIONS) {+ const page = await browser.newPage({+ viewport: { width: WIDTH, height: HEIGHT },+ deviceScaleFactor: scale+ });+ await page.goto(`${SOURCE.href}?variant=${variant}`);+ const outputPath = path.join(DMG_DIR, `${baseName}${suffix}.png`);+ await page.screenshot({ path: outputPath, clip: { x: 0, y: 0, width: WIDTH, height: HEIGHT } });+ await page.close();+ console.log(`[${variant} ${scale}x] ${outputPath}`);+ }+ }+} finally {+ await browser.close();+}diff --git a/apps/desktop/electron-forge/forge.config.ts b/apps/desktop/electron-forge/forge.config.tsindex d69c2ad586..c13741b31f 100644--- a/apps/desktop/electron-forge/forge.config.ts+++ b/apps/desktop/electron-forge/forge.config.ts@@ -152,7 +152,21 @@ const config: ForgeConfig = {{name: "@electron-forge/maker-dmg",config: {- icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev.icns" : "icon.icns")+ icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev.icns" : "icon.icns"),+ // Branded Finder-window background (generated from dmg-background/background.html).+ // appdmg auto-uses the sibling [email protected] for Retina.+ background: path.join(ELECTRON_FORGE_DIR, "dmg-background", isNightly ? "background-dev.png" : "background.png"),+ iconSize: 128,+ additionalDMGOptions: {+ window: { size: { width: 640, height: 400 } }+ },+ // Icon CENTERS in a bottom-left coordinate space, matched to the platforms in+ // background.html. These need a macOS test-build to fine-tune: the DMG can only+ // be built and visually verified there (appdmg is darwin-only).+ contents: (opts: { appPath: string }) => [+ { x: 180, y: 185, type: "file", path: opts.appPath },+ { x: 460, y: 185, type: "link", path: "/Applications" }+ ]}},{diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 306825d567..de5c5818ce 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -22,6 +22,7 @@"electron-forge:start": "pnpm build && electron-forge start dist","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","test": "vitest --config vitest.config.mts"},"dependencies": {