Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 63 additions & 35 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
});
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/release-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down