From f8678a91ec7e588cc14601db7622d0ee0adf7108 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Sun, 10 Dec 2023 23:44:58 +0100 Subject: [PATCH] Hide Heynote when global hotkey is pressed if the window is already focused --- electron/main/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 414744e..6b79383 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -153,9 +153,16 @@ function registerGlobalHotkey() { if (CONFIG.get("settings.enableGlobalHotkey")) { try { const ret = globalShortcut.register(CONFIG.get("settings.globalHotkey"), () => { - app.focus({steal: true}) - if (win?.isMinimized()) { - win?.restore() + if (!win) { + return + } + if (win.isFocused()) { + app.hide() + } else { + app.focus({steal: true}) + if (win.isMinimized()) { + win.restore() + } } }) } catch (error) {