(hotkey: string)
| 3089 | } |
| 3090 | |
| 3091 | function registerQuickCaptureHotkey(hotkey: string): { ok: boolean; error?: string } { |
| 3092 | unregisterQuickCaptureHotkey() |
| 3093 | const trimmed = hotkey.trim() |
| 3094 | if (!trimmed) return { ok: true } |
| 3095 | try { |
| 3096 | const ok = globalShortcut.register(trimmed, () => { |
| 3097 | console.info(`[zen:quick-capture] hotkey pressed: ${trimmed}`) |
| 3098 | void toggleQuickCaptureWindow() |
| 3099 | }) |
| 3100 | if (!ok) { |
| 3101 | return { ok: false, error: `Failed to register quick capture hotkey: ${trimmed}` } |
| 3102 | } |
| 3103 | if (!globalShortcut.isRegistered(trimmed)) { |
| 3104 | return { ok: false, error: `Quick capture hotkey was not registered by the system: ${trimmed}` } |
| 3105 | } |
| 3106 | registeredQuickCaptureHotkey = trimmed |
| 3107 | console.info(`[zen:quick-capture] registered hotkey: ${trimmed}`) |
| 3108 | return { ok: true } |
| 3109 | } catch (err) { |
| 3110 | const message = err instanceof Error ? err.message : String(err) |
| 3111 | return { ok: false, error: message } |
| 3112 | } |
| 3113 | } |
| 3114 | |
| 3115 | // Set the app name before the ready event so the dock / menu bar / |
| 3116 | // About panel all show "ZenNotes" instead of the default "Electron" |
no test coverage detected