diff --git a/electron/main.js b/electron/main.js index 4630f586..def40922 100644 --- a/electron/main.js +++ b/electron/main.js @@ -25,6 +25,22 @@ import contextMenu from 'electron-context-menu'; import FormData from 'form-data'; import fetch from 'node-fetch'; +// Linux startup hardening: default to X11 ozone and sanitize env to avoid GTK mixups +const isLinux = process.platform === 'linux'; +if (isLinux && !process.env.SEEDIT_NO_ENV_SANITIZE) { + // Default to X11 unless the user explicitly sets a hint + if (!process.env.ELECTRON_OZONE_PLATFORM_HINT) { + process.env.ELECTRON_OZONE_PLATFORM_HINT = 'x11'; + } + // Unset common injectors known to trigger mixed GTK majors + delete process.env.GTK_MODULES; + delete process.env.GTK_PATH; + delete process.env.LD_PRELOAD; +} + +// Keep a global Tray reference to prevent GC removing the tray icon +let tray; + // Determine __filename and dirname for ESM const __filename = fileURLToPath(import.meta.url); const dirname = path.dirname(__filename); @@ -325,45 +341,57 @@ const createMainWindow = () => { }); if (process.platform !== 'darwin') { - // tray - const trayIconPath = path.join(dirname, '..', isDev ? 'public' : 'build', 'electron-tray-icon.png'); - const tray = new Tray(trayIconPath); - tray.setToolTip('seedit'); - const trayMenu = Menu.buildFromTemplate([ - { - label: 'Open seedit', - click: () => { - mainWindow.show(); + const isWayland = + process.platform === 'linux' && + (process.env.XDG_SESSION_TYPE === 'wayland' || process.env.WAYLAND_DISPLAY || process.env.ELECTRON_OZONE_PLATFORM_HINT === 'wayland'); + const trayDisabled = isWayland && process.env.SEEDIT_ENABLE_TRAY !== '1'; + + if (!trayDisabled) { + // tray + const trayIconPath = path.join(dirname, '..', isDev ? 'public' : 'build', 'electron-tray-icon.png'); + if (tray) { + try { + tray.destroy(); + } catch (e) {} + } + tray = new Tray(trayIconPath); + tray.setToolTip('seedit'); + const trayMenu = Menu.buildFromTemplate([ + { + label: 'Open seedit', + click: () => { + mainWindow.show(); + }, }, - }, - { - label: 'Quit seedit', - click: () => { - mainWindow.destroy(); - app.quit(); + { + label: 'Quit seedit', + click: () => { + mainWindow.destroy(); + app.quit(); + }, }, - }, - ]); - tray.setContextMenu(trayMenu); - - // show/hide on tray right click - tray.on('right-click', () => { - mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); - }); + ]); + tray.setContextMenu(trayMenu); - // close to tray - if (!isDev) { - let isQuiting = false; - app.on('before-quit', () => { - isQuiting = true; - }); - mainWindow.on('close', (event) => { - if (!isQuiting) { - event.preventDefault(); - mainWindow.hide(); - event.returnValue = false; - } + // show/hide on tray right click + tray.on('right-click', () => { + mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); }); + + // close to tray + if (!isDev) { + let isQuiting = false; + app.on('before-quit', () => { + isQuiting = true; + }); + mainWindow.on('close', (event) => { + if (!isQuiting) { + event.preventDefault(); + mainWindow.hide(); + event.returnValue = false; + } + }); + } } } diff --git a/scripts/release-body.js b/scripts/release-body.js index 8888ff4e..5167d5c3 100644 --- a/scripts/release-body.js +++ b/scripts/release-body.js @@ -103,7 +103,7 @@ const htmlSection = section('Static HTML build', [ const downloads = [macSection, winSection, linuxSection, androidSection, htmlSection] .filter(Boolean).join('\n\n'); -const releaseBody = `This version improves desktop performance and adds native builds. +const releaseBody = `This version fixes a bug that prevented the desktop app from opening in specific Linux environments. It also includes a plebbit-react-hooks fix for the user's wallet signature timestamps, which were invalid. - Web app: https://seedit.app - Decentralized web app via IPFS/IPNS gateways (works on any browser): [seedit.eth.limo](https://seedit.eth.limo), [seedit.eth.link](https://seedit.eth.link), [dweb.link/ipfs.io](https://dweb.link/ipns/seedit.eth)