Screensharing rework

Split Linux screensharing audio tracks, Rework screensharing functionality and layout
This will need some refactoring soon
This commit is contained in:
2026-03-08 06:33:27 +01:00
parent d20509566d
commit 7a4c4ede8c
42 changed files with 4998 additions and 475 deletions

View File

@@ -0,0 +1,65 @@
import { app } from 'electron';
import * as fs from 'fs';
import * as path from 'path';
export interface DesktopSettings {
hardwareAcceleration: boolean;
}
export interface DesktopSettingsSnapshot extends DesktopSettings {
runtimeHardwareAcceleration: boolean;
restartRequired: boolean;
}
const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
hardwareAcceleration: true
};
export function getDesktopSettingsSnapshot(): DesktopSettingsSnapshot {
const storedSettings = readDesktopSettings();
const runtimeHardwareAcceleration = app.isHardwareAccelerationEnabled();
return {
...storedSettings,
runtimeHardwareAcceleration,
restartRequired: storedSettings.hardwareAcceleration !== runtimeHardwareAcceleration
};
}
export function readDesktopSettings(): DesktopSettings {
const filePath = getDesktopSettingsPath();
try {
if (!fs.existsSync(filePath)) {
return { ...DEFAULT_DESKTOP_SETTINGS };
}
const raw = fs.readFileSync(filePath, 'utf8');
const parsed = JSON.parse(raw) as Partial<DesktopSettings>;
return {
hardwareAcceleration: typeof parsed.hardwareAcceleration === 'boolean'
? parsed.hardwareAcceleration
: DEFAULT_DESKTOP_SETTINGS.hardwareAcceleration
};
} catch {
return { ...DEFAULT_DESKTOP_SETTINGS };
}
}
export function updateDesktopSettings(patch: Partial<DesktopSettings>): DesktopSettingsSnapshot {
const nextSettings: DesktopSettings = {
...readDesktopSettings(),
...patch
};
const filePath = getDesktopSettingsPath();
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, JSON.stringify(nextSettings, null, 2), 'utf8');
return getDesktopSettingsSnapshot();
}
function getDesktopSettingsPath(): string {
return path.join(app.getPath('userData'), 'desktop-settings.json');
}