Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix(desktop): show each app's real icon in the library on macOS

Luis Ortiz73bc91712285
diff --git a/apps/desktop/src/main/app-icon.ts b/apps/desktop/src/main/app-icon.ts
index 5b264fa..67b2d44 100644
--- a/apps/desktop/src/main/app-icon.ts
+++ b/apps/desktop/src/main/app-icon.ts
@@ -1,14 +1,25 @@
import { isAbsolute } from 'node:path';
-import { app, protocol } from 'electron';
+import { app, type NativeImage, nativeImage, protocol } from 'electron';
export const APP_ICON_SCHEME = 'mimik-app-icon';
+const ICON_PX = 64;
+
+async function iconFor(path: string): Promise<NativeImage> {
+ if (process.platform === 'darwin') {
+ const thumbnail = await nativeImage
+ .createThumbnailFromPath(path, { width: ICON_PX, height: ICON_PX })
+ .catch(() => null);
+ if (thumbnail && !thumbnail.isEmpty()) return thumbnail;
+ }
+ return app.getFileIcon(path, { size: 'normal' });
+}
export function registerAppIconProtocol(): void {
protocol.handle(APP_ICON_SCHEME, async (request) => {
const path = new URL(request.url).searchParams.get('path');
if (!path || !isAbsolute(path)) return new Response(null, { status: 404 });
try {
- const icon = await app.getFileIcon(path, { size: 'normal' });
+ const icon = await iconFor(path);
if (icon.isEmpty()) return new Response(null, { status: 404 });
return new Response(new Uint8Array(icon.toPNG()), { headers: { 'content-type': 'image/png' } });
} catch {