mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-12 04:19:25 -07:00
feat: wire session bindings through main, ipc, and cli runtime
This commit is contained in:
@@ -20,42 +20,6 @@ export interface RegisterGlobalShortcutsServiceOptions {
|
||||
}
|
||||
|
||||
export function registerGlobalShortcuts(options: RegisterGlobalShortcutsServiceOptions): void {
|
||||
const visibleShortcut = options.shortcuts.toggleVisibleOverlayGlobal;
|
||||
const normalizedVisible = visibleShortcut?.replace(/\s+/g, '').toLowerCase();
|
||||
const normalizedJimaku = options.shortcuts.openJimaku?.replace(/\s+/g, '').toLowerCase();
|
||||
const normalizedSettings = 'alt+shift+y';
|
||||
|
||||
if (visibleShortcut) {
|
||||
const toggleVisibleRegistered = globalShortcut.register(visibleShortcut, () => {
|
||||
options.onToggleVisibleOverlay();
|
||||
});
|
||||
if (!toggleVisibleRegistered) {
|
||||
logger.warn(
|
||||
`Failed to register global shortcut toggleVisibleOverlayGlobal: ${visibleShortcut}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.shortcuts.openJimaku && options.onOpenJimaku) {
|
||||
if (
|
||||
normalizedJimaku &&
|
||||
(normalizedJimaku === normalizedVisible || normalizedJimaku === normalizedSettings)
|
||||
) {
|
||||
logger.warn(
|
||||
'Skipped registering openJimaku because it collides with another global shortcut',
|
||||
);
|
||||
} else {
|
||||
const openJimakuRegistered = globalShortcut.register(options.shortcuts.openJimaku, () => {
|
||||
options.onOpenJimaku?.();
|
||||
});
|
||||
if (!openJimakuRegistered) {
|
||||
logger.warn(
|
||||
`Failed to register global shortcut openJimaku: ${options.shortcuts.openJimaku}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const settingsRegistered = globalShortcut.register('Alt+Shift+Y', () => {
|
||||
options.onOpenYomitanSettings();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user