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
5 changes: 5 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ Changing the services themselves also means running their own tests — see

## Build

`npm run generate:icons` stages the application icons from `resources/app-icon/`.
The macOS menu bar uses `pair-tray-template.png`, a transparent monochrome version
of PAIR's symbol, rendered at standard and Retina resolutions. Keep its background
transparent so macOS can adapt the template to light and dark menu bars.

```bash
npm run build # renderer, main, preload, and CLI bundles
```
Expand Down
2 changes: 1 addition & 1 deletion desktop/electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function copyIconsPlugin() {
resolve(__dirname, 'out/resources/icons'),
resolve(__dirname, 'resources/icons')
]
// Only the flat logo.* files are needed at runtime (tray.ts / window.ts).
// Only the flat icon files are needed at runtime (tray.ts / window.ts).
// Skip subdirectories such as linux/, which is consumed by electron-builder
// at package time, not by the running app — copyFileSync on a dir throws.
const files = readdirSync(src, { withFileTypes: true })
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions desktop/scripts/build/generate-app-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* resources/icons/logo.png <- pair-1024.png (tray/window downscale)
* resources/icons/logo.ico <- pair.ico (Windows builder)
* resources/icons/logo.icns <- assembled from the sized PNGs (macOS builder)
* resources/icons/pairTrayTemplate.png <- transparent macOS menu bar symbol
* resources/icons/linux/<N>x<N>.png <- freedesktop hicolor set (Linux builder)
* src/ui/public/favicon.png <- pair-256.png (renderer favicon)
*
Expand Down Expand Up @@ -86,6 +87,9 @@ function assertSources(): void {
}
}
if (!existsSync(resolve(srcDir, 'pair.ico'))) problems.push('pair.ico is missing')
if (!existsSync(resolve(srcDir, 'pair-tray-template.png'))) {
problems.push('pair-tray-template.png is missing')
}
if (problems.length > 0) {
throw new Error(
'Invalid source icons in resources/app-icon/:\n - ' +
Expand Down Expand Up @@ -121,6 +125,10 @@ function copyStaticIcons(): void {

copyFileSync(master, resolve(iconsDir, 'logo.png'))
copyFileSync(ico, resolve(iconsDir, 'logo.ico'))
copyFileSync(
resolve(srcDir, 'pair-tray-template.png'),
resolve(iconsDir, 'pairTrayTemplate.png')
)

copyFileSync(srcPngPath(256), resolve(faviconDir, 'favicon.png'))
}
Expand Down Expand Up @@ -148,6 +156,7 @@ function main(): void {
console.log(
'Generated app icons:\n' +
' resources/icons/logo.{png,ico,icns}\n' +
' resources/icons/pairTrayTemplate.png\n' +
` resources/icons/linux/<N>x<N>.png (${linuxIconSizes.join(', ')})\n` +
' src/ui/public/favicon.png'
)
Expand Down
16 changes: 9 additions & 7 deletions desktop/src/electron/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ class TrayManager {
const iconsDir = join(__dirname, '../../resources/icons')

if (currentPlatform() === 'darwin') {
let image = nativeImage.createFromPath(join(iconsDir, 'logo.png'))
image = image.resize({ width: 16, height: 16, quality: 'best' })
try {
image.setTemplateImage(true)
} catch {
/* not supported in test env */
}
const source = nativeImage.createFromPath(
join(__dirname, '../resources/icons/pairTrayTemplate.png')
)
const image = source.resize({ width: 18, height: 18, quality: 'best' })
image.addRepresentation({
scaleFactor: 2,
buffer: source.resize({ width: 36, height: 36, quality: 'best' }).toPNG()
})
image.setTemplateImage(true)
return image
}

Expand Down
Loading