Skip to content

Commit

Permalink
Merge pull request #4267 from rauenzi/tray
Browse files Browse the repository at this point in the history
Add hotkey option to toggle hide to tray
  • Loading branch information
zadam authored Sep 22, 2023
2 parents 40ca949 + 9d69024 commit 2e69cc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/public/app/components/root_command_executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import openService from "../services/open.js";
import protectedSessionService from "../services/protected_session.js";
import options from "../services/options.js";
import froca from "../services/froca.js";
import utils from "../services/utils.js";

export default class RootCommandExecutor extends Component {
editReadOnlyNoteCommand() {
Expand Down Expand Up @@ -155,6 +156,15 @@ export default class RootCommandExecutor extends Component {
}
}

toggleTrayCommand() {
if (!utils.isElectron()) return;
const {BrowserWindow} = utils.dynamicRequire('@electron/remote');
const windows = BrowserWindow.getAllWindows();
const isVisible = windows.every(w => w.isVisible());
const action = isVisible ? "hide" : "show"
for (const window of windows) window[action]();
}

firstTabCommand() { this.#goToTab(1); }
secondTabCommand() { this.#goToTab(2); }
thirdTabCommand() { this.#goToTab(3); }
Expand Down
6 changes: 6 additions & 0 deletions src/services/keyboard_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
description: "Open new empty window",
scope: "window"
},
{
actionName: "toggleTray",
defaultShortcuts: [],
description: "Shows/hides the application from the system tray",
scope: "window"
},
{
actionName: "firstTab",
defaultShortcuts: ["CommandOrControl+1"],
Expand Down

0 comments on commit 2e69cc8

Please sign in to comment.