From 46ee34d49970492a435d19fc21da4e9a4c1e0f2f Mon Sep 17 00:00:00 2001 From: DhanushSantosh Date: Thu, 26 Feb 2026 10:53:58 +0530 Subject: [PATCH] fix: resolve desktop entry launch failure and hide Electron menu bar on Linux - Add --ozone-platform-hint=auto before app.whenReady() so Electron auto-detects X11 vs Wayland when launched from a desktop entry where the display protocol is not guaranteed (fixes immediate crash on Fedora/GNOME Wayland sessions) - Add autoHideMenuBar: true to BrowserWindow so the default Chromium File/Edit/View/Help menu bar is hidden by default (still accessible via Alt); removes visible Electron significance from the packaged app - Add scripts/rpm-after-install.sh and wire it via afterInstall in the electron-builder RPM config to chmod 4755 chrome-sandbox, ensuring the setuid sandbox works on kernels with restricted user namespaces Co-Authored-By: Claude Sonnet 4.6 --- apps/ui/package.json | 3 ++- apps/ui/scripts/rpm-after-install.sh | 6 ++++++ apps/ui/src/electron/windows/main-window.ts | 3 +++ apps/ui/src/main.ts | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 apps/ui/scripts/rpm-after-install.sh diff --git a/apps/ui/package.json b/apps/ui/package.json index 7b2c35f1..0d04a111 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -275,7 +275,8 @@ "libuuid" ], "compression": "xz", - "vendor": "AutoMaker Team" + "vendor": "AutoMaker Team", + "afterInstall": "scripts/rpm-after-install.sh" }, "nsis": { "oneClick": false, diff --git a/apps/ui/scripts/rpm-after-install.sh b/apps/ui/scripts/rpm-after-install.sh new file mode 100644 index 00000000..06f59500 --- /dev/null +++ b/apps/ui/scripts/rpm-after-install.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Set the setuid bit on chrome-sandbox so Electron's sandbox works on systems +# where unprivileged user namespaces are restricted (e.g. hardened kernels). +# On Fedora/RHEL with standard kernel settings this is not strictly required, +# but it is a safe no-op when not needed. +chmod 4755 /opt/Automaker/chrome-sandbox 2>/dev/null || true diff --git a/apps/ui/src/electron/windows/main-window.ts b/apps/ui/src/electron/windows/main-window.ts index 49ec5e1b..9e9282db 100644 --- a/apps/ui/src/electron/windows/main-window.ts +++ b/apps/ui/src/electron/windows/main-window.ts @@ -46,6 +46,9 @@ export function createWindow(): void { contextIsolation: true, nodeIntegration: false, }, + // Hide the default Electron/Chromium menu bar on Linux (File/Edit/View/Help). + // It still appears on Alt-press so keyboard-only users aren't locked out. + autoHideMenuBar: true, // titleBarStyle is macOS-only; use hiddenInset for native look on macOS ...(process.platform === 'darwin' && { titleBarStyle: 'hiddenInset' as const }), backgroundColor: '#0a0a0a', diff --git a/apps/ui/src/main.ts b/apps/ui/src/main.ts index 7e32f077..80a2e837 100644 --- a/apps/ui/src/main.ts +++ b/apps/ui/src/main.ts @@ -48,6 +48,13 @@ if (isDev) { } } +// On Linux, auto-detect X11 vs Wayland so the app launches correctly from +// desktop entries where the display protocol isn't guaranteed to be X11. +// Must be set before app.whenReady() — has no effect on macOS/Windows. +if (process.platform === 'linux') { + app.commandLine.appendSwitch('ozone-platform-hint', 'auto'); +} + // Register IPC handlers registerAllHandlers();