Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: add setting to disable menu bar (#3728)

Muhammad Ali636783335f33
diff --git a/apps/desktop/src/api/os-integration.ts b/apps/desktop/src/api/os-integration.ts
index 016246d5c..03baa3b54 100644
--- a/apps/desktop/src/api/os-integration.ts
+++ b/apps/desktop/src/api/os-integration.ts
@@ -53,6 +53,15 @@ export const osIntegrationRouter = t.router({
config.zoomFactor = factor;
}),
+ menuBar: t.procedure.query(() => config.menuBar),
+ setMenuBar: t.procedure
+ .input(z.object({ enabled: z.boolean() }))
+ .mutation(({ input: { enabled } }) => {
+ config.menuBar = enabled;
+ if (!enabled) globalThis.window?.setMenuBarVisibility(false);
+ globalThis.window?.setAutoHideMenuBar(enabled);
+ }),
+
privacyMode: t.procedure.query(() => config.privacyMode),
setPrivacyMode: t.procedure
.input(z.object({ enabled: z.boolean() }))
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 7d053a651..99c2de4e7 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -77,7 +77,7 @@ async function createWindow() {
darkTheme: getTheme() === "dark",
backgroundColor: getBackgroundColor(),
opacity: 0,
- autoHideMenuBar: true,
+ autoHideMenuBar: config.menuBar,
icon: AssetManager.appIcon({
size: 512,
format: process.platform === "win32" ? "ico" : "png"
@@ -93,6 +93,7 @@ async function createWindow() {
createIPCHandler({ router, windows: [mainWindow] });
globalThis.window = mainWindow;
+ mainWindow.setMenuBarVisibility(false);
mainWindowState.manage(mainWindow);
if (cliOptions.hidden && !config.desktopSettings.minimizeToSystemTray)
diff --git a/apps/desktop/src/utils/config.ts b/apps/desktop/src/utils/config.ts
index 59a261183..ba736956c 100644
--- a/apps/desktop/src/utils/config.ts
+++ b/apps/desktop/src/utils/config.ts
@@ -41,7 +41,8 @@ export const config = {
isSpellCheckerEnabled: true,
zoomFactor: 1,
theme: nativeTheme.themeSource,
- automaticUpdates: true
+ automaticUpdates: true,
+ menuBar: true
};
type ConfigKey = keyof typeof config;
diff --git a/apps/web/src/dialogs/settings/behaviour-settings.ts b/apps/web/src/dialogs/settings/behaviour-settings.ts
index d08e865f6..becca2958 100644
--- a/apps/web/src/dialogs/settings/behaviour-settings.ts
+++ b/apps/web/src/dialogs/settings/behaviour-settings.ts
@@ -22,6 +22,7 @@ import { SettingsGroup } from "./types";
import { useStore as useSettingStore } from "../../stores/setting-store";
import dayjs from "dayjs";
import { isUserPremium } from "../../hooks/use-is-user-premium";
+import { isMac } from "../../utils/platform";
export const BehaviourSettings: SettingsGroup[] = [
{
@@ -136,10 +137,10 @@ export const BehaviourSettings: SettingsGroup[] = [
]
},
{
- key: "updates",
+ key: "desktop-app",
section: "behaviour",
- header: "Updates",
- isHidden: () => useSettingStore.getState().isFlatpak,
+ header: "Desktop app",
+ isHidden: () => !IS_DESKTOP_APP,
settings: [
{
key: "auto-updates",
@@ -148,6 +149,7 @@ export const BehaviourSettings: SettingsGroup[] = [
"Automatically download & install updates in the background without prompting first.",
onStateChange: (listener) =>
useSettingStore.subscribe((s) => s.autoUpdates, listener),
+ isHidden: () => useSettingStore.getState().isFlatpak,
components: [
{
type: "toggle",
@@ -155,6 +157,20 @@ export const BehaviourSettings: SettingsGroup[] = [
toggle: () => useSettingStore.getState().toggleAutoUpdates()
}
]
+ },
+ {
+ key: "menu-bar",
+ title: "Disable menu bar",
+ description:
+ "Disable menu bar so it remains hidden even when Alt key is pressed.",
+ isHidden: () => isMac(),
+ components: [
+ {
+ type: "toggle",
+ isToggled: () => !useSettingStore.getState().menuBar,
+ toggle: () => useSettingStore.getState().toggleMenuBar()
+ }
+ ]
}
]
}
diff --git a/apps/web/src/stores/setting-store.js b/apps/web/src/stores/setting-store.js
index 2c83bc54b..b4c25ca3b 100644
--- a/apps/web/src/stores/setting-store.js
+++ b/apps/web/src/stores/setting-store.js
@@ -58,6 +58,7 @@ class SettingStore extends BaseStore {
desktopIntegrationSettings = undefined;
autoUpdates = true;
isFlatpak = false;
+ menuBar = true;
refresh = async () => {
this.set({
@@ -70,7 +71,8 @@ class SettingStore extends BaseStore {
await desktop?.integration.desktopIntegration.query(),
privacyMode: await desktop?.integration.privacyMode.query(),
zoomFactor: await desktop?.integration.zoomFactor.query(),
- autoUpdates: await desktop?.updater.autoUpdates.query()
+ autoUpdates: await desktop?.updater.autoUpdates.query(),
+ menuBar: await desktop?.integration.menuBar.query()
});
};
@@ -182,6 +184,14 @@ class SettingStore extends BaseStore {
this.set({ autoUpdates: !autoUpdates });
await desktop?.updater.toggleAutoUpdates.mutate({ enabled: !autoUpdates });
};
+
+ toggleMenuBar = async () => {
+ const menuBar = this.get().menuBar;
+ this.set({ menuBar: !menuBar });
+ await desktop?.integration.setMenuBar.mutate({
+ enabled: !menuBar
+ });
+ };
}
const [useStore, store] = createStore(SettingStore);
diff --git a/apps/web/src/utils/platform.ts b/apps/web/src/utils/platform.ts
index 58737ff02..bcbcb2517 100644
--- a/apps/web/src/utils/platform.ts
+++ b/apps/web/src/utils/platform.ts
@@ -129,5 +129,5 @@ export function isMac() {
}
export function isMacStoreApp() {
- return window.os && window.os() === "mas";
+ return window.os ? window.os() === "mas" : false;
}