Files
Toju/electron/app/flags.ts
2026-03-09 21:12:06 +01:00

58 lines
1.8 KiB
TypeScript

import { app } from 'electron';
import { readDesktopSettings } from '../desktop-settings';
export function configureAppFlags(): void {
linuxSpecificFlags();
audioFlags();
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');
}
function audioFlags(): void {
if (process.platform === 'linux') {
// Use the new PipeWire-based audio pipeline on Linux for better screen share audio capture support
app.commandLine.appendSwitch('enable-features', 'AudioServiceOutOfProcess');
}
}
function linuxSpecificFlags(): void {
// Disable sandbox on Linux to avoid SUID / /tmp shared-memory issues
if (process.platform === 'linux') {
app.commandLine.appendSwitch('no-sandbox');
app.commandLine.appendSwitch('disable-dev-shm-usage');
}
}
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();
}
if (process.platform === 'linux' && desktopSettings.vaapiVideoEncode) {
// Enable VA-API hardware video encoding on Linux
app.commandLine.appendSwitch('enable-features', 'VaapiVideoEncode');
}
app.commandLine.appendSwitch('enable-gpu-rasterization');
app.commandLine.appendSwitch('enable-zero-copy');
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers');
}