diff options
author | Michael Hays <michaelhays36@gmail.com> | 2021-10-02 22:22:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-03 08:52:01 +0530 |
commit | 0c584dcbb06cb12556141dcd3f65ea1ebebe58ce (patch) | |
tree | 0aa380600e284c4506b52e9668a5e228109cafca /src | |
parent | refactor: use correct datatypes in ts files (diff) | |
download | ferdium-app-0c584dcbb06cb12556141dcd3f65ea1ebebe58ce.tar.gz ferdium-app-0c584dcbb06cb12556141dcd3f65ea1ebebe58ce.tar.zst ferdium-app-0c584dcbb06cb12556141dcd3f65ea1ebebe58ce.zip |
feat: add a globalShortcut to toggle main window (#2002)
Fixes #1663
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js index 87f45e7fc..d947d96ca 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable import/first */ | 1 | /* eslint-disable import/first */ |
2 | 2 | ||
3 | import { app, BrowserWindow, ipcMain, session, dialog } from 'electron'; | 3 | import { app, BrowserWindow, globalShortcut, ipcMain, session, dialog } from 'electron'; |
4 | 4 | ||
5 | import { emptyDirSync, ensureFileSync } from 'fs-extra'; | 5 | import { emptyDirSync, ensureFileSync } from 'fs-extra'; |
6 | import { join } from 'path'; | 6 | import { join } from 'path'; |
@@ -17,6 +17,7 @@ import { | |||
17 | isMac, | 17 | isMac, |
18 | isWindows, | 18 | isWindows, |
19 | isLinux, | 19 | isLinux, |
20 | altKey, | ||
20 | } from './environment'; | 21 | } from './environment'; |
21 | import { | 22 | import { |
22 | isDevMode, | 23 | isDevMode, |
@@ -360,6 +361,13 @@ const createWindow = () => { | |||
360 | } else { | 361 | } else { |
361 | mainWindow.show(); | 362 | mainWindow.show(); |
362 | } | 363 | } |
364 | |||
365 | app.whenReady().then(() => { | ||
366 | // Toggle the window on 'Alt+X' | ||
367 | globalShortcut.register(`${altKey()}+X`, () => { | ||
368 | trayIcon.trayMenuTemplate[0].click(); | ||
369 | }); | ||
370 | }); | ||
363 | }; | 371 | }; |
364 | 372 | ||
365 | // Allow passing command line parameters/switches to electron | 373 | // Allow passing command line parameters/switches to electron |