feat(desktop): add KeybindManager with uiohook-napi for global shortcuts

Installs uiohook-napi for OS-level non-consuming input hooks, creates
KeybindManager class that receives keybind configs from the renderer,
matches the OS-wide key/mouse event stream, and sends matched actions
back via IPC. Exposes syncKeybinds, onKeybindAction, onAccessibilityStatus,
onKeybindHookError, and checkAccessibility APIs through the preload bridge.
This commit is contained in:
Jannis Braun
2026-03-22 20:47:41 +01:00
parent 11d802f86c
commit 3ce9ee0db0
5 changed files with 213 additions and 2 deletions
+14
View File
@@ -14,8 +14,10 @@ import {
import path from 'path';
import fs from 'fs';
import { startActivityDetection, stopActivityDetection, getCurrentActivity } from './activityDetector';
import { KeybindManager } from './keybindManager';
let mainWindow: BrowserWindow | null = null;
const keybindManager = new KeybindManager();
let tray: Tray | null = null;
let isQuitting = false;
let pendingDeepLink: string | null = null;
@@ -276,6 +278,8 @@ function createWindow(): void {
},
});
keybindManager.setWindow(mainWindow);
if (savedState.isMaximized) {
mainWindow.maximize();
}
@@ -545,6 +549,15 @@ function registerIpcHandlers(): void {
return updated;
});
// Keybinds
ipcMain.on('keybinds-sync', (_event, keybinds) => {
keybindManager.updateKeybinds(keybinds);
});
ipcMain.handle('check-accessibility', () => {
return keybindManager.checkAccessibility();
});
}
// ─── Auto-Update ────────────────────────────────────────────────────────────
@@ -810,5 +823,6 @@ if (!gotTheLock) {
app.on('before-quit', () => {
isQuitting = true;
stopActivityDetection();
keybindManager.stop();
});
}