(rawGlobalHotKey: string)
| 1061 | let currentGlobalHotKey: string = null; |
| 1062 | |
| 1063 | export function registerGlobalHotkey(rawGlobalHotKey: string) { |
| 1064 | if (rawGlobalHotKey === currentRawGlobalHotKey) { |
| 1065 | return; |
| 1066 | } |
| 1067 | if (currentGlobalHotKey != null) { |
| 1068 | globalShortcut.unregister(currentGlobalHotKey); |
| 1069 | currentGlobalHotKey = null; |
| 1070 | currentRawGlobalHotKey = null; |
| 1071 | } |
| 1072 | if (!rawGlobalHotKey) { |
| 1073 | return; |
| 1074 | } |
| 1075 | try { |
| 1076 | const electronHotKey = waveKeyToElectronKey(rawGlobalHotKey); |
| 1077 | const ok = globalShortcut.register(electronHotKey, () => { |
| 1078 | fireAndForget(quakeToggle); |
| 1079 | }); |
| 1080 | currentRawGlobalHotKey = rawGlobalHotKey; |
| 1081 | currentGlobalHotKey = electronHotKey; |
| 1082 | console.log("registered globalhotkey", rawGlobalHotKey, "=>", electronHotKey, "ok=", ok); |
| 1083 | } catch (e) { |
| 1084 | console.log("error registering global hotkey", rawGlobalHotKey, ":", e); |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | export function initGlobalHotkeyEventSubscription() { |
| 1089 | waveEventSubscribeSingle({ |
no test coverage detected