Skip to content

Build your personal knowledge base with Trilium Notes

feat(desktop): give the DMG its own drive volume icon

Elian Doran645338118342
diff --git a/apps/desktop/electron-forge/dmg-background/README.md b/apps/desktop/electron-forge/dmg-background/README.md
index 7b20f30b2d..89e7a62b29 100644
--- a/apps/desktop/electron-forge/dmg-background/README.md
+++ b/apps/desktop/electron-forge/dmg-background/README.md
@@ -17,8 +17,9 @@ them on a real macOS build.
`preview.png` (stable) and `preview-dev.png` (nightly) are faithful mocks of the assembled Finder window:
the real app icon (`icon.icns` / `icon-dev.icns`) and the real macOS Applications-folder icon composited at
-the same `contents` coordinates the DMG uses, under a reconstructed Finder title bar, with the captions
-Finder draws. On macOS the icons are rendered from their `.icns` via `sips` (pixel-perfect); off macOS it
+the same `contents` coordinates the DMG uses, under a reconstructed Finder title bar carrying the real
+volume icon (`../dmg-icon/volume.icns` — the drive, which is what Finder titles the window with, *not* the
+app icon), with the captions Finder draws. On macOS the icons are rendered from their `.icns` via `sips` (pixel-perfect); off macOS it
falls back to the flat logo and a drawn folder so the script still runs anywhere. They are **reference
only** — appdmg never uses them (it only reads `background.png`/`@2x`). Kept reproducible from source so
they aren't mystery images; regenerate with `pnpm --filter desktop generate-dmg-preview`.
diff --git a/apps/desktop/electron-forge/dmg-background/preview-dev.png b/apps/desktop/electron-forge/dmg-background/preview-dev.png
index ba1c3a7afb..8d534dd3a1 100644
Binary files a/apps/desktop/electron-forge/dmg-background/preview-dev.png and b/apps/desktop/electron-forge/dmg-background/preview-dev.png differ
diff --git a/apps/desktop/electron-forge/dmg-background/preview.mjs b/apps/desktop/electron-forge/dmg-background/preview.mjs
index c1b8884824..964d6a1742 100644
--- a/apps/desktop/electron-forge/dmg-background/preview.mjs
+++ b/apps/desktop/electron-forge/dmg-background/preview.mjs
@@ -22,6 +22,7 @@ import { chromium } from "@playwright/test";
const DMG_DIR = path.dirname(fileURLToPath(import.meta.url));
const APP_ICON_DIR = path.join(DMG_DIR, "..", "app-icon");
+const DMG_ICON_DIR = path.join(DMG_DIR, "..", "dmg-icon");
// --- Layout: mirrors the real DMG (keep in sync with forge.config.ts) ---
const WIDTH = 640; // content = the background image
@@ -35,25 +36,9 @@ const APP = { x: 180, label: "Trilium Notes" };
const APPS = { x: 460, label: "Applications" };
const APPLICATIONS_ICNS = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ApplicationsFolderIcon.icns";
-// Leaf `d` paths for the title-bar volume-icon mark (order: g1 g2 g3 o1 o2 o3 r1 r2 r3), plus the
-// stable and nightly fills — reused from background.html's mark.
-const LEAF_PATHS = [
- "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",
- "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",
- "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",
- "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",
- "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",
- "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",
- "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",
- "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",
- "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"
-];
-const STABLE_LEAVES = ["#95c980", "#72b755", "#4fa52b", "#efb075", "#e99547", "#e47b19", "#ee8c89", "#e96562", "#e33f3b"];
-const NIGHTLY_LEAVES = ["#b18ad6", "#9159c4", "#6e2ea8", "#c09fe0", "#a276cf", "#8146b8", "#cdb2e4", "#b08fd6", "#9668c2"];
-
const VARIANTS = [
- { bg: "background.png", icns: "icon.icns", pngFallback: "128x128.png", leaves: STABLE_LEAVES, out: "preview.png" },
- { bg: "background-dev.png", icns: "icon-dev.icns", pngFallback: "128x128-dev.png", leaves: NIGHTLY_LEAVES, out: "preview-dev.png" }
+ { bg: "background.png", icns: "icon.icns", pngFallback: "128x128.png", volumeIcns: "volume.icns", out: "preview.png" },
+ { bg: "background-dev.png", icns: "icon-dev.icns", pngFallback: "128x128-dev.png", volumeIcns: "volume-dev.icns", out: "preview-dev.png" }
];
// Drawn stand-in used only when the real macOS Applications icon isn't available.
@@ -104,18 +89,15 @@ function extractIcns(icns, workDir, outName) {
}
}
-/** The trillium leaf mark for the title bar, coloured for the given channel. */
-function trilliumMark(leaves) {
- const paths = LEAF_PATHS.map((d, i) => `<path fill="${leaves[i]}" d="${d}"/>`).join("");
- return `<svg viewBox="0 0 256 256" aria-hidden="true">${paths}</svg>`;
-}
-
function buildHtml(variant) {
const bgHref = pathToFileURL(path.join(DMG_DIR, variant.bg)).href;
const appIconHref =
extractIcns(path.join(APP_ICON_DIR, variant.icns), work, `app-${variant.out}.png`) ??
pathToFileURL(path.join(APP_ICON_DIR, "png", variant.pngFallback)).href;
const appsGlyph = appsIconHref ? `<img class="icon" src="${appsIconHref}">` : FOLDER_FALLBACK;
+ // Finder titles the window with the VOLUME icon — the drive, not the app icon.
+ const volumeHref = extractIcns(path.join(DMG_ICON_DIR, variant.volumeIcns), work, `vol-${variant.out}.png`);
+ const volumeGlyph = volumeHref ? `<img class="volume" src="${volumeHref}">` : "";
return `<!doctype html><meta charset="utf-8"><style>
html, body { margin: 0; padding: 0; background: transparent; }
.stage { padding: ${MARGIN}px; width: ${WIDTH}px; }
@@ -134,7 +116,7 @@ function buildHtml(variant) {
.lights i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.12); }
.lights .r { background: #ff5f57; } .lights .y { background: #febc2e; } .lights .g { background: #28c840; }
.title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #3a3a3a; }
- .title svg { width: 16px; height: 16px; display: block; }
+ .title .volume { width: 16px; height: 16px; display: block; }
.content { position: relative; width: ${WIDTH}px; height: ${HEIGHT}px; }
.content .bg { position: absolute; inset: 0; width: ${WIDTH}px; height: ${HEIGHT}px; }
.item { position: absolute; width: ${ICON}px; height: ${ICON}px; transform: translate(-50%, -50%); }
@@ -150,7 +132,7 @@ function buildHtml(variant) {
<div class="stage"><div class="win">
<div class="titlebar">
<span class="lights"><i class="r"></i><i class="y"></i><i class="g"></i></span>
- <span class="title">${trilliumMark(variant.leaves)} Trilium Notes</span>
+ <span class="title">${volumeGlyph} Trilium Notes</span>
</div>
<div class="content">
<img class="bg" src="${bgHref}">
diff --git a/apps/desktop/electron-forge/dmg-background/preview.png b/apps/desktop/electron-forge/dmg-background/preview.png
index 4f376110f3..116e491737 100644
Binary files a/apps/desktop/electron-forge/dmg-background/preview.png and b/apps/desktop/electron-forge/dmg-background/preview.png differ
diff --git a/apps/desktop/electron-forge/dmg-icon/README.md b/apps/desktop/electron-forge/dmg-icon/README.md
new file mode 100644
index 0000000000..d96cb2f780
--- /dev/null
+++ b/apps/desktop/electron-forge/dmg-icon/README.md
@@ -0,0 +1,91 @@
+# macOS DMG volume icon
+
+`volume.icns` / `volume-dev.icns` (nightly) are the icon of the **mounted disk image** — Finder's
+sidebar under Locations, the desktop mount, the DMG window's title bar, the eject menu. appdmg
+copies the file in as `.VolumeIcon.icns`; wired up as `icon` in `electron-forge/forge.config.ts`.
+
+Generated from `volume-icon.html`; don't edit the `.icns` by hand. Change the HTML and regenerate:
+
+```bash
+pnpm --filter desktop generate-dmg-icon
+```
+
+## Previews
+
+`preview-large.png` and `preview-small.png` show the icon **without building or mounting a DMG**
+(which needs macOS + appdmg) — the large one at Finder icon-view / desktop-mount size, the small one
+at the two sizes Finder actually paints small: the DMG window's title bar and the sidebar, 1:1, with
+the 16 and 32 slots magnified 6× so the pixels are inspectable. Both cover both channels.
+
+```bash
+pnpm --filter desktop generate-dmg-icon-preview
+```
+
+They are **extracted from the committed `.icns`**, not re-rendered from the HTML, so they show what
+actually ships and double as a check that the packed file contains what we think it does. Reference
+only — appdmg never reads them. Regenerate them whenever the `.icns` changes.
+
+## What this is *not*
+
+**Not the `.dmg` file icon in Downloads.** That one comes from the disk-image UTI. Overriding it
+needs a resource-fork custom icon, which HTTP downloads don't carry (it's a `com.apple.ResourceFork`
+xattr) and which would dirty the file after CI's `codesign`/`stapler` pass. Not worth chasing — the
+mounted-volume icon is the whole win available.
+
+**Not the app icon.** It used to be: `forge.config.ts` pointed `icon` straight at `app-icon/icon.icns`,
+so the mounted volume was indistinguishable from the installed app.
+
+## Design
+
+**The form is Apple's own, measured rather than guessed.** The reference is the icon macOS itself
+shows for a mounted DMG that carries no custom volume icon — obtained from `NSWorkspace.icon(forFile:)`
+against a throwaway `hdiutil`-created image, not from an approximation of it. On a 1024 canvas that
+reference measures:
+
+| | |
+|---|---|
+| Body | 719 × 877 at (152, 74) — **portrait**, aspect 0.82 |
+| Corner radius | ~60 (fitted against the corner's inset-per-row profile) |
+| Base plinth | bottom ~12% of the body, full width, silver, with an LED right of centre |
+| Glyph | centred in the area *above* the plinth |
+| Body tone | ~243 at the top falling to ~235 near the base, with a bright rim / dark hairline / interior edge profile |
+
+Matching it means the icon reads as a disk image in the system's own language instead of as a bespoke
+box. The one deliberate departure is the glyph: Apple's grey download arrow becomes the brand mark in
+full colour, which is the entire point of shipping our own.
+
+An earlier attempt used a **landscape** body with a dark inset face plate and a wide media slot,
+loosely after Firefox's. It's a defensible look — Firefox's is a variation on Apple's older *external
+drive* icon — but it is not what a disk image looks like on this system, and the landscape silhouette
+reads as a display. Don't go back to it without a reason.
+
+The mark is **single-sourced** from `apps/client/src/assets/icon-color.svg` and `icon-nightly.svg`,
+loaded as a `file://` image at render time. This folder deliberately keeps no copy of the leaf paths.
+
+## Sizes
+
+**One artwork, scaled to every slot** — the drive body stays intact down to 16pt. At that size the
+*silhouette* is what identifies the volume; the mark only has to hold up as a legible colour blob.
+Swapping in a bare mark at the small slots throws away the one cue that still reads.
+
+**One exception, and it matters: the body outline can't live in design space.** Every other element
+is an *area*, so it shrinks gracefully. A stroke is a *width* — a fixed 5 design units is 0.08 device
+px at the 16pt slot, i.e. gone, taking the drive silhouette with it and leaving the mark floating on
+a white blob. Apple sidesteps this by hand-tuning their small slots. `volume-icon.html` derives the
+stroke width from the slot scale instead (`max(5, 1.1 / scale)`), which gets the same result from one
+artwork: ~1.1 device px at the small slots, proportionate once the icon is big enough to carry it.
+**If you add another stroked element, give it the same treatment.**
+
+The design is authored in a 1024 box and scaled per slot via a CSS factor, so each slot rasterises
+from vectors instead of downsampling one bitmap.
+
+## Output contract
+
+- Ten `.iconset` slots: 16, 16@2x, 32, 32@2x, 128, 128@2x, 256, 256@2x, 512, 512@2x.
+- PNG slots render on **any OS** (headless Chromium via the repo's `@playwright/test`). Packing them
+ into `.icns` uses `iconutil`, which is **macOS-only** — elsewhere the script leaves the `.iconset`
+ on disk and the committed `.icns` untouched. No worse than the status quo: the DMG itself can only
+ be *built* on macOS anyway (appdmg is darwin-only).
+- Current `iconutil` emits `ic04`/`ic05` for the 1× 16/32 slots (older toolchains, including whatever
+ built Firefox's, emit legacy `is32`/`s8mk` + `il32`/`l8mk` RLE instead). Both are fine on supported
+ macOS versions; don't "fix" the difference.
diff --git a/apps/desktop/electron-forge/dmg-icon/generate.mts b/apps/desktop/electron-forge/dmg-icon/generate.mts
new file mode 100644
index 0000000000..16c12c2280
--- /dev/null
+++ b/apps/desktop/electron-forge/dmg-icon/generate.mts
@@ -0,0 +1,102 @@
+/**
+ * Regenerates the macOS DMG volume icon (volume.icns + volume-dev.icns) from volume-icon.html.
+ *
+ * Run with: pnpm --filter desktop generate-dmg-icon
+ *
+ * This is the icon of the MOUNTED disk image — Finder's sidebar under Locations, the desktop
+ * mount, the DMG window's title bar, the eject menu. appdmg copies it in as `.VolumeIcon.icns`
+ * (wired up as `icon` in forge.config.ts). It is NOT the .dmg file icon in Downloads: that one
+ * comes from the disk-image UTI and can only be overridden by a resource-fork custom icon, which
+ * HTTP downloads don't carry and which would dirty the file after CI's codesign/staple pass.
+ *
+ * It deliberately does NOT reuse the app icon. A drive body distinguishes "installer media" from
+ * "the app", which is the whole point; Firefox's own volume icon is the reference, and it keeps
+ * the drive body intact all the way down to the 16pt slot rather than swapping in a bare mark.
+ *
+ * The PNG slots render on any OS (headless Chromium via the repo's @playwright/test). Packing them
+ * into an .icns uses `iconutil`, which is macOS-only — elsewhere the .iconset is left on disk and
+ * the committed .icns is untouched. That's no worse than the status quo: the DMG itself can only
+ * be BUILT on macOS anyway (appdmg is darwin-only).
+ */
+import { execFileSync } from "child_process";
+import { mkdirSync, rmSync, writeFileSync } from "fs";
+import path from "path";
+import { fileURLToPath, pathToFileURL } from "url";
+
+import { chromium } from "@playwright/test";
+
+const DMG_ICON_DIR = path.dirname(fileURLToPath(import.meta.url));
+const SOURCE = pathToFileURL(path.join(DMG_ICON_DIR, "volume-icon.html"));
+const CLIENT_ASSETS = path.join(DMG_ICON_DIR, "..", "..", "..", "client", "src", "assets");
+
+/** The design is authored in a 1024 box; every slot is a vector render scaled from it. */
+const DESIGN_SIZE = 1024;
+
+/**
+ * The ten slots an .iconset must provide, as {file name → pixel size}. Sizes repeat across slots
+ * (a 256px render serves both `256x256` and `128x128@2x`) exactly as Finder expects, so only the
+ * distinct pixel sizes are actually rendered.
+ */
+const SLOTS: Record<string, number> = {
+ "icon_16x16.png": 16,
+ "icon_32x32.png": 32,
+ "icon_128x128.png": 128,
+ "icon_256x256.png": 256,
+ "icon_512x512.png": 512,
+};
+
+/**
+ * One volume icon per channel. The mark is read from the client's own icon SVGs so the leaves stay
+ * single-sourced — this folder never gets its own copy of the leaf paths.
+ */
+const VARIANTS = [
+ { mark: "icon-color.svg", baseName: "volume" },
+ { mark: "icon-nightly.svg", baseName: "volume-dev" }
+];
+
+const browser = await chromium.launch();
+try {
+ for (const { mark, baseName } of VARIANTS) {
+ const iconsetDir = path.join(DMG_ICON_DIR, `${baseName}.iconset`);
+ rmSync(iconsetDir, { recursive: true, force: true });
+ mkdirSync(iconsetDir, { recursive: true });
+
+ const markUrl = pathToFileURL(path.join(CLIENT_ASSETS, mark)).href;
+ const renders = new Map<number, Buffer>();
+
+ for (const size of new Set(Object.values(SLOTS))) {
+ // Served from a file:// origin so the browser is allowed to load the file:// mark.
+ const page = await browser.newPage({ viewport: { width: size, height: size } });
+ const query = `scale=${size / DESIGN_SIZE}&mark=${encodeURIComponent(markUrl)}`;
+ await page.goto(`${SOURCE.href}?${query}`);
+ renders.set(size, await page.screenshot({ omitBackground: true }));
+ await page.close();
+ }
+
+ for (const [fileName, size] of Object.entries(SLOTS)) {
+ const render = renders.get(size);
+ if (!render) {
+ throw new Error(`No render for slot ${fileName} (${size}px)`);
+ }
+ writeFileSync(path.join(iconsetDir, fileName), render);
+ }
+
+ if (process.platform !== "darwin") {
+ console.warn(`[${baseName}] iconset written to ${iconsetDir};`
+ + " run iconutil on macOS to pack the .icns");
+ continue;
+ }
+
+ const icnsPath = path.join(DMG_ICON_DIR, `${baseName}.icns`);
+ execFileSync("iconutil", ["-c", "icns", iconsetDir, "-o", icnsPath]);
+ rmSync(iconsetDir, { recursive: true, force: true });
+ console.log(`[${baseName}] ${icnsPath}`);
+ }
+} finally {
+ await browser.close();
+}
diff --git a/apps/desktop/electron-forge/dmg-icon/preview-large.png b/apps/desktop/electron-forge/dmg-icon/preview-large.png
new file mode 100644
index 0000000000..0711c51bf2
Binary files /dev/null and b/apps/desktop/electron-forge/dmg-icon/preview-large.png differ
diff --git a/apps/desktop/electron-forge/dmg-icon/preview-small.png b/apps/desktop/electron-forge/dmg-icon/preview-small.png
new file mode 100644
index 0000000000..d8cc037e29
Binary files /dev/null and b/apps/desktop/electron-forge/dmg-icon/preview-small.png differ
diff --git a/apps/desktop/electron-forge/dmg-icon/preview.mjs b/apps/desktop/electron-forge/dmg-icon/preview.mjs
new file mode 100644
index 0000000000..d73366cf95
--- /dev/null
+++ b/apps/desktop/electron-forge/dmg-icon/preview.mjs
@@ -0,0 +1,173 @@
+/**
+ * Renders the volume-icon previews — so the icon can be judged without building a DMG (which needs
+ * macOS + appdmg) or mounting one.
+ *
+ * Run with: pnpm --filter desktop generate-dmg-icon-preview
+ *
+ * preview-large.png the icon at Finder icon-view / desktop-mount size, both channels
+ * preview-small.png the sizes Finder actually paints small — the DMG window's title bar and the
+ * sidebar — at 1:1, with the 16 and 32 slots magnified so the pixels are
+ * inspectable (a 16px image on its own tells you nothing)
+ *
+ * Documentation only: appdmg never sees these, it only reads the .icns.
+ *
+ * FIDELITY. The slots are extracted from the committed .icns rather than re-rendered from
+ * volume-icon.html, so what you are looking at is what actually ships — this doubles as a check
+ * that the packed file contains what we think it does. The window chrome is drawn by Finder, not
+ * by us; it is reconstructed here only so the small sizes are shown in the context they appear in.
+ *
+ * Extraction uses `iconutil`, so this is macOS-only. Elsewhere the committed PNGs are left alone —
+ * same stance as generate.mts, and no worse than the status quo, since the DMG can only be built
+ * on macOS anyway.
+ */
+import { execFileSync } from "child_process";
+import { mkdtempSync, rmSync, writeFileSync } from "fs";
+import { tmpdir } from "os";
+import path from "path";
+import { fileURLToPath, pathToFileURL } from "url";
+
+import { chromium } from "@playwright/test";
+
+const DMG_ICON_DIR = path.dirname(fileURLToPath(import.meta.url));
+
+/** Keep in sync with the volume name appdmg gives the image (the app's product name). */
+const VOLUME_NAME = "Trilium Notes";
+const TITLEBAR_HEIGHT = 28;
+const ZOOM = 6; // magnification for the small slots
+
+const PAGE_CSS = `
+ html, body { margin: 0; padding: 0; }
+ body {
+ background: #ffffff; color: #1d1d1f;
+ font-family: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
+ /* min-height, not height: the shot is taken fullPage, so the viewport is a floor rather
+ than a clip — content taller than it extends the image instead of being cut off. */
+ min-height: 100vh; padding: 30px; box-sizing: border-box;
+ }
+ .caption { font-size: 12px; color: #6b6b70; }
+ .channel-name { font-size: 13px; font-weight: 600; }
+`;
+
+const CHANNELS = [
+ { label: "Stable", icns: "volume.icns" },
+ { label: "Nightly", icns: "volume-dev.icns" }
+];
+
+if (process.platform !== "darwin") {
+ console.warn("dmg-icon previews need `iconutil` (macOS-only);"
+ + " leaving the committed PNGs alone");
+ process.exit(0);
+}
+
+const work = mkdtempSync(path.join(tmpdir(), "dmg-icon-preview-"));
+try {
+ for (const channel of CHANNELS) {
+ const iconsetDir = path.join(work, `${channel.label}.iconset`);
+ const icns = path.join(DMG_ICON_DIR, channel.icns);
+ execFileSync("iconutil", ["-c", "iconset", icns, "-o", iconsetDir]);
+ channel.slot = (name) => pathToFileURL(path.join(iconsetDir, name)).href;
+ }
+
+ const browser = await chromium.launch();
+ try {
+ await shoot(browser, buildLarge(), "preview-large.png", 640, 400);
+ await shoot(browser, buildSmall(), "preview-small.png", 760, 420);
+ } finally {
+ await browser.close();
+ }
+} finally {
+ rmSync(work, { recursive: true, force: true });
+}
+
+async function shoot(browser, html, outName, width, height) {
+ const htmlPath = path.join(work, `${outName}.html`);
+ writeFileSync(htmlPath, html);
+ // Served from a file:// origin so the browser is allowed to load the file:// slot images.
+ const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 2 });
+ await page.goto(pathToFileURL(htmlPath).href);
+ const outputPath = path.join(DMG_ICON_DIR, outName);
+ await page.screenshot({ path: outputPath, fullPage: true });
+ await page.close();
+ console.log(outputPath);
+}
+
+/** The icon at the size Finder shows it on the desktop / in icon view. */
+function buildLarge() {
+ // The 512 slot displayed at 256 CSS px on a 2x page is pixel-exact — no resampling.
+ const columns = CHANNELS.map((c) => `
+ <div class="col">
+ <img class="icon" src="${c.slot("icon_512x512.png")}">
+ <div class="channel-name">${c.label}</div>
+ <div class="caption">256 pt</div>
+ </div>`).join("");
+ return `<!doctype html><meta charset="utf-8"><style>${PAGE_CSS}
+ .row { display: flex; gap: 72px; }
+ .col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
+ .icon { width: 256px; height: 256px; }
+ </style><div class="row">${columns}</div>`;
+}
+
+/** The two places Finder paints the volume icon small, plus magnified slots. */
+function buildSmall() {
+ const rows = CHANNELS.map((c) => `
+ <div class="block">
+ <div class="channel-name">${c.label}</div>
+ <div class="titlebar">
+ <span class="lights"><i class="r"></i><i class="y"></i><i class="g"></i></span>
+ <span class="title"><img src="${c.slot("icon_16x16.png")}"> ${VOLUME_NAME}</span>
+ </div>
+ <div class="caption">DMG window title bar, 1:1</div>
+ <div class="zoom-row">
+ <div class="zoom-col">
+ <img class="zoom" src="${c.slot("icon_16x16.png")}" width="${16 * ZOOM}">
+ <div class="caption">16 pt @${ZOOM}x</div>
+ </div>
+ <div class="zoom-col">
+ <img class="zoom" src="${c.slot("icon_32x32.png")}" width="${32 * ZOOM}">
+ <div class="caption">32 pt @${ZOOM}x</div>
+ </div>
+ <div class="zoom-col sidebar">
+ <span class="sidebar-row">
+ <img src="${c.slot("icon_16x16.png")}"> ${VOLUME_NAME}
+ </span>
+ <div class="caption">sidebar, 1:1</div>
+ </div>
+ </div>
+ </div>`).join("");
+ return `<!doctype html><meta charset="utf-8"><style>${PAGE_CSS}
+ body { gap: 34px; }
+ .block { display: flex; flex-direction: column; align-items: center; gap: 7px; }
+ .titlebar {
+ position: relative; width: 340px; height: ${TITLEBAR_HEIGHT}px; margin-top: 3px;
+ background: linear-gradient(180deg, #f6f6f6 0%, #e7e7e7 100%);
+ border: 1px solid #cdcdcd; border-radius: 8px 8px 0 0;
+ display: flex; align-items: center; justify-content: center;
+ }
+ .lights {
+ position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
+ display: flex; gap: 7px;
+ }
+ .lights i {
+ width: 11px; height: 11px; border-radius: 50%;
+ box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.12);
+ }
+ .lights .r { background: #ff5f57; }
+ .lights .y { background: #febc2e; }
+ .lights .g { background: #28c840; }
+ .title {
+ display: flex; align-items: center; gap: 5px;
+ font-size: 13px; font-weight: 600; color: #3a3a3a;
+ }
+ .title img { width: 16px; height: 16px; }
+ .zoom-row { display: flex; align-items: flex-end; gap: 26px; margin-top: 9px; }
+ .zoom-col { display: flex; flex-direction: column; align-items: center; gap: 7px; }
+ /* Nearest-neighbour: the point is to see the actual pixels, not a smoothed idea of them. */
+ .zoom { image-rendering: pixelated; }
+ .sidebar-row {
+ display: flex; align-items: center; gap: 6px; font-size: 13px;
+ background: #f2f2f4; border-radius: 6px; padding: 7px 11px;
+ }
+ .sidebar-row img { width: 16px; height: 16px; }
+ </style>${rows}`;
+}
diff --git a/apps/desktop/electron-forge/dmg-icon/volume-dev.icns b/apps/desktop/electron-forge/dmg-icon/volume-dev.icns
new file mode 100644
index 0000000000..c069910d81
Binary files /dev/null and b/apps/desktop/electron-forge/dmg-icon/volume-dev.icns differ
diff --git a/apps/desktop/electron-forge/dmg-icon/volume-icon.html b/apps/desktop/electron-forge/dmg-icon/volume-icon.html
new file mode 100644
index 0000000000..cedd922468
--- /dev/null
+++ b/apps/desktop/electron-forge/dmg-icon/volume-icon.html
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Trilium DMG volume icon</title>
+<style>
+ html, body { margin: 0; padding: 0; background: transparent; }
+
+ /* The design is authored once in a 1024 x 1024 box and scaled to the target slot size by
+ generate.mts (--scale), so every slot is rendered from vectors instead of downsampled from
+ one bitmap. Chromium rasterises the SVG at the scaled device resolution, which keeps the
+ 16pt sidebar slot as crisp as the 1024 one. */
+ .stage {
+ width: 1024px;
+ height: 1024px;
+ transform: scale(var(--scale, 1));
+ transform-origin: 0 0;
+ }
+ svg { display: block; }
+</style>
+</head>
+<body>
+<div class="stage" id="stage">
+ <!-- Geometry measured off the icon macOS itself shows for a DMG with no custom volume icon
+ (NSWorkspace icon for a mounted, unbranded image), so this reads as a disk image in the
+ system's own form language rather than as a bespoke box. On a 1024 canvas that reference
+ is: body 719 x 877 at (152, 74) — portrait, aspect 0.82 — corner radius ~60, and a silver
+ base plinth occupying the bottom ~12%, with the glyph centred in the area above it. The
+ only deliberate departure is the glyph: Apple's grey download arrow becomes the brand
+ mark, in full colour, which is the entire point of shipping our own. -->
+ <svg viewBox="0 0 1024 1024" width="1024" height="1024" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <!-- Body: near-white with a faint vertical fall-off, matching the reference's
+ 243-at-top / 235-near-the-base readings. -->
+ <linearGradient id="body" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="#fafafc"/>
+ <stop offset="0.45" stop-color="#eeeff2"/>
+ <stop offset="1" stop-color="#dcdee3"/>
+ </linearGradient>
+ <!-- Moulded plastic edge, sampled across the reference's left edge: a bright rim, a
+ darker hairline a few px in, then the interior. This is what stops the body
+ reading as a flat rectangle — and at the 16pt slot the outline is most of
+ what still says "drive", so it is deliberately stronger than the reference's. -->
+ <linearGradient id="edge" x1="0" y1="0" x2="1" y2="0">
+ <stop offset="0" stop-color="#d9dade" stop-opacity="1"/>
+ <stop offset="0.015" stop-color="#c7c8cd" stop-opacity="1"/>
+ <stop offset="0.045" stop-color="#eceded" stop-opacity="0.75"/>
+ <stop offset="0.12" stop-color="#ffffff" stop-opacity="0"/>
+ <stop offset="0.88" stop-color="#ffffff" stop-opacity="0"/>
+ <stop offset="0.955" stop-color="#e4e5e8" stop-opacity="0.75"/>
+ <stop offset="0.985" stop-color="#c5c6cb" stop-opacity="1"/>
+ <stop offset="1" stop-color="#d6d7db" stop-opacity="1"/>
+ </linearGradient>
+ <!-- Base plinth: brushed silver, darker than the body so the silhouette has a foot. -->
+ <linearGradient id="plinth" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="#c4c6cc"/>
+ <stop offset="0.55" stop-color="#b2b4bb"/>
+ <stop offset="1" stop-color="#a2a4ac"/>
+ </linearGradient>
+ <!-- Rounded bottom corners are the body's, so the plinth is drawn clipped to it. -->
+ <clipPath id="bodyClip">
+ <rect x="152" y="74" width="719" height="877" rx="60"/>
+ </clipPath>
+ <filter id="shade" x="-20%" y="-20%" width="140%" height="140%">
+ <feDropShadow dx="0" dy="10" stdDeviation="14" flood-color="#4c5261" flood-opacity="0.34"/>
+ </filter>
+ </defs>
+
+ <g filter="url(#shade)">
+ <rect x="152" y="74" width="719" height="877" rx="60" fill="url(#body)"/>
+
+ <g clip-path="url(#bodyClip)">
+ <!-- Plinth, its seam, and the highlight the reference catches just below it. -->
+ <rect x="152" y="845" width="719" height="106" fill="url(#plinth)"/>
+ <rect x="152" y="838" width="719" height="7" fill="#82858c" fill-opacity="0.55"/>
+ <rect x="152" y="845" width="719" height="4" fill="#ffffff" fill-opacity="0.85"/>
+ <!-- Activity LED, right of centre on the plinth. -->
+ <circle cx="790" cy="898" r="14" fill="#ffffff" fill-opacity="0.92"/>
+ </g>
+
+ <rect x="152" y="74" width="719" height="877" rx="60" fill="url(#edge)"/>
+ <!-- Outline width is set per slot by the script below, NOT fixed here. See the note
+ there: a constant design-space stroke vanishes at the small slots. -->
+ <rect id="outline" x="152" y="74" width="719" height="877" rx="60" fill="none"
+ stroke="#868c99" stroke-opacity="0.85"/>
+ </g>
+
+ <!-- Brand mark, single-sourced from the client's icon SVG (injected by generate.mts).
+ Centred in the area above the plinth, where the reference puts its arrow, and sized
+ to ~58% of the body width so it still reads as colour at the 16pt slot. -->
+ <image id="mark" x="302" y="238" width="420" height="420" preserveAspectRatio="xMidYMid meet"/>
+ </svg>
+</div>
+<script>
+ const params = new URLSearchParams(location.search);
+ const scale = parseFloat(params.get("scale") ?? "1");
+ document.getElementById("stage").style.setProperty("--scale", scale);
+ document.getElementById("mark").setAttribute("href", params.get("mark") ?? "");
+
+ // The body outline is the one part that cannot live in design space. Everything else is an
+ // area, so it shrinks gracefully; a stroke is a *width*, and a fixed 5 design units is 0.08
+ // device px at the 16pt slot — i.e. gone, taking the drive silhouette with it and leaving the
+ // mark floating on a white blob. Apple avoids this by hand-tuning their small slots. Deriving
+ // the width from the slot scale gets the same result from one artwork: ~1.1 device px at the
+ // small slots, and a proportionate 5 units once the icon is big enough to carry it.
+ document.getElementById("outline").setAttribute("stroke-width", Math.max(5, 1.1 / scale));
+</script>
+</body>
+</html>
diff --git a/apps/desktop/electron-forge/dmg-icon/volume.icns b/apps/desktop/electron-forge/dmg-icon/volume.icns
new file mode 100644
index 0000000000..f7170728b7
Binary files /dev/null and b/apps/desktop/electron-forge/dmg-icon/volume.icns differ
diff --git a/apps/desktop/electron-forge/forge.config.ts b/apps/desktop/electron-forge/forge.config.ts
index c1cdcd9477..053a9a0f3a 100644
--- a/apps/desktop/electron-forge/forge.config.ts
+++ b/apps/desktop/electron-forge/forge.config.ts
@@ -149,7 +149,12 @@ const config: ForgeConfig = {
{
name: "@electron-forge/maker-dmg",
config: {
- icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev.icns" : "icon.icns"),
+ // Volume icon of the MOUNTED image (Finder sidebar, desktop mount, DMG
+ // title bar) — a drive body carrying the mark, NOT the app icon, so the
+ // installer reads as media rather than a second copy of the app.
+ // Generated from dmg-icon/volume-icon.html; see that folder's README.
+ icon: path.join(ELECTRON_FORGE_DIR, "dmg-icon",
+ isNightly ? "volume-dev.icns" : "volume.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"),
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index e0d8460c67..899ffd2f1a 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -23,6 +23,8 @@
"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-icon": "tsx electron-forge/dmg-icon/generate.mts",
+ "generate-dmg-icon-preview": "tsx electron-forge/dmg-icon/preview.mjs",
"generate-dmg-preview": "tsx electron-forge/dmg-background/preview.mjs",
"test": "vitest --config vitest.config.mts"
},