Skip to content

Commit a3bdeec

Browse files
grimmerkclaude
andcommitted
feat: add mode toggle to tray right-click menu
Shows 'Switch to Menu Bar Mode' or 'Switch to Normal App Mode' at the top of the tray context menu. Reuses the same IPC logic as the Settings toggle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cf3d53d commit a3bdeec

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/TrayGenerator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class TrayGenerator {
2121
tray: Tray;
2222
attachedWindow: BrowserWindow;
2323
onTrayClickCallback: any;
24+
onToggleAppMode: (() => void) | null = null;
25+
getAppMode: (() => string) | null = null;
2426
title: string;
2527
shortcuts: ShortcutSettings = {
2628
quickSwitcher: 'Command+Control+R',
@@ -83,7 +85,17 @@ export class TrayGenerator {
8385
},
8486
];
8587

88+
const currentMode = this.getAppMode ? this.getAppMode() : 'normal';
89+
const modeLabel = currentMode === 'normal' ? 'Switch to Menu Bar Mode' : 'Switch to Normal App Mode';
90+
8691
const menu: any = [
92+
{
93+
label: modeLabel,
94+
click: () => {
95+
if (this.onToggleAppMode) this.onToggleAppMode();
96+
},
97+
},
98+
{ type: 'separator' },
8799
{
88100
label: 'Settings',
89101
submenu: settingsItems,

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,12 @@ const trayToggleEvtHandler = async () => {
12941294
}
12951295

12961296
tray = new TrayGenerator(switcherWindow, title, trayToggleEvtHandler);
1297+
tray.getAppMode = () => appMode;
1298+
tray.onToggleAppMode = () => {
1299+
const newMode = appMode === 'normal' ? 'menubar' : 'normal';
1300+
// Reuse the same logic as the IPC handler
1301+
require('electron').ipcMain.emit('set-app-mode', {}, newMode);
1302+
};
12971303

12981304
// https://www.electronjs.org/docs/latest/tutorial/keyboard-shortcuts#global-shortcuts
12991305

0 commit comments

Comments
 (0)