MCPcopy
hub / github.com/wavetermdev/waveterm / registerGlobalHotkey

Function registerGlobalHotkey

emain/emain-window.ts:1063–1086  ·  view source on GitHub ↗
(rawGlobalHotKey: string)

Source from the content-addressed store, hash-verified

1061let currentGlobalHotKey: string = null;
1062
1063export 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
1088export function initGlobalHotkeyEventSubscription() {
1089 waveEventSubscribeSingle({

Callers 2

appMainFunction · 0.90

Calls 2

waveKeyToElectronKeyFunction · 0.90
fireAndForgetFunction · 0.90

Tested by

no test coverage detected