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:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user