Files
Toju/electron/app/flags.ts
Myx be465fd297
All checks were successful
Queue Release Build / prepare (push) Successful in 14s
Queue Release Build / build-windows (push) Successful in 34m25s
Queue Release Build / build-linux (push) Successful in 40m26s
Queue Release Build / finalize (push) Successful in 3m44s
Fix screenshare portals linux
2026-03-11 17:54:04 +01:00

71 lines
2.3 KiB
TypeScript

import { app } from 'electron';
import { readDesktopSettings } from '../desktop-settings';
export function configureAppFlags(): void {
linuxSpecificFlags();
networkFlags();
setupGpuEncodingFlags();
chromiumFlags();
}
function chromiumFlags(): void {
// Allow media autoplay without user gesture
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
// Suppress Autofill devtools errors
app.commandLine.appendSwitch('disable-features', 'Autofill,AutofillAssistant,AutofillServerCommunication');
// Collect all enabled features into a single switch to avoid later calls overwriting earlier ones
const enabledFeatures: string[] = [];
if (process.platform === 'linux') {
// PipeWire-based audio pipeline for screen share audio capture
enabledFeatures.push('AudioServiceOutOfProcess');
// PipeWire-based screen capture so the xdg-desktop-portal system picker works
enabledFeatures.push('WebRTCPipeWireCapturer');
}
const desktopSettings = readDesktopSettings();
if (process.platform === 'linux' && desktopSettings.vaapiVideoEncode) {
enabledFeatures.push('VaapiVideoEncode');
}
if (enabledFeatures.length > 0) {
app.commandLine.appendSwitch('enable-features', enabledFeatures.join(','));
}
}
function linuxSpecificFlags(): void {
if (process.platform !== 'linux') {
return;
}
// Disable sandbox on Linux to avoid SUID / /tmp shared-memory issues
app.commandLine.appendSwitch('no-sandbox');
app.commandLine.appendSwitch('disable-dev-shm-usage');
// Auto-detect Wayland vs X11 so the xdg-desktop-portal system picker
// works for screen capture on Wayland compositors
app.commandLine.appendSwitch('ozone-platform-hint', 'auto');
}
function networkFlags(): void {
// Accept self-signed certificates in development (for --ssl dev server)
if (process.env['SSL'] === 'true') {
app.commandLine.appendSwitch('ignore-certificate-errors');
}
}
function setupGpuEncodingFlags(): void {
const desktopSettings = readDesktopSettings();
if (!desktopSettings.hardwareAcceleration) {
app.disableHardwareAcceleration();
}
app.commandLine.appendSwitch('enable-gpu-rasterization');
app.commandLine.appendSwitch('enable-zero-copy');
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers');
}