mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
22 lines
666 B
TypeScript
22 lines
666 B
TypeScript
import { FileService } from "@/app/store/services";
|
|
import { fireAndForget } from "@/util/util";
|
|
import { app, globalShortcut } from "electron";
|
|
|
|
async function hotkeyCallback() {
|
|
app.focus();
|
|
}
|
|
|
|
export async function configureGlobalHotkey() {
|
|
const settings = (await FileService.GetFullConfig())?.settings;
|
|
|
|
const globalhotkey = settings["window:globalhotkey"];
|
|
if (globalhotkey) {
|
|
console.log(`Registering global hotkey: "${globalhotkey}"`);
|
|
|
|
await app.whenReady();
|
|
globalShortcut.register(globalhotkey, () => fireAndForget(() => hotkeyCallback()));
|
|
}
|
|
|
|
app.on("before-quit", () => globalShortcut.unregisterAll());
|
|
}
|