Files
orca/src/shared/app-icon.ts
T
Neil 009def47a6 feat(app-icon): import a custom app icon from Appearance settings (#39443)
Adds a Custom… option to the App Icon switcher. The picked PNG/JPEG is
header-checked before decoding (square, 64–2048 px, ≤10 MB), re-encoded as
PNG into userData, and applied to the macOS Dock and every window icon. It
persists across restarts and can be removed, which resets to Classic.

Closes #13316
2026-11-07 18:22:37 -08:00

42 lines
1.3 KiB
TypeScript

export const APP_ICON_OPTIONS = [
{ id: 'classic', label: 'Classic Orca' },
{ id: 'watercolor', label: 'Watercolor Orca' },
{ id: 'blue', label: 'Blue Orca' }
] as const
export type BuiltInAppIconId = (typeof APP_ICON_OPTIONS)[number]['id']
// Why one id, not a stored path: the imported image always lives at a fixed userData location.
export const CUSTOM_APP_ICON_ID = 'custom'
export type AppIconId = BuiltInAppIconId | typeof CUSTOM_APP_ICON_ID
export const DEFAULT_APP_ICON_ID: BuiltInAppIconId = 'classic'
function isAppIconId(value: unknown): value is AppIconId {
return value === CUSTOM_APP_ICON_ID || APP_ICON_OPTIONS.some((option) => option.id === value)
}
export function normalizeAppIconId(value: unknown): AppIconId {
return isAppIconId(value) ? value : DEFAULT_APP_ICON_ID
}
export const CUSTOM_APP_ICON_MAX_BYTES = 10 * 1024 * 1024
export const CUSTOM_APP_ICON_MIN_SIDE = 64
// Why 2048: decoding runs on the main process, and the stored copy is downscaled to 1024 anyway.
export const CUSTOM_APP_ICON_MAX_SIDE = 2048
export type CustomAppIconImportFailureCode =
| 'unsupportedFormat'
| 'unreadable'
| 'tooLarge'
| 'notSquare'
| 'tooSmall'
| 'tooBig'
| 'undecodable'
| 'saveFailed'
export type CustomAppIconImportResult =
| { ok: true; previewDataUrl: string }
| { ok: false; code: CustomAppIconImportFailureCode }