Skip to content

Commit

Permalink
Hide Heynote when global hotkey is pressed if the window is already f…
Browse files Browse the repository at this point in the history
…ocused
  • Loading branch information
heyman committed Dec 10, 2023
1 parent 9e50446 commit f8678a9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f8678a9

Please sign in to comment.