OpenAsar/src/cmdSwitches.js

28 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-12-21 10:38:18 +00:00
const { app } = require('electron');
const presets = {
'base': '--autoplay-policy=no-user-gesture-required --disable-features=WinRetrieveSuggestionsOnlyOnDemand,HardwareMediaKeyHandling,MediaSessionService', // Base Discord
2022-03-01 19:13:37 +00:00
'perf': `--enable-gpu-rasterization --enable-zero-copy --ignore-gpu-blocklist --enable-hardware-overlays=single-fullscreen,single-on-top,underlay --enable-features=EnableDrDc,CanvasOopRasterization,BackForwardCache:TimeToLiveInBackForwardCacheInSeconds/300/should_ignore_blocklists/true/enable_same_site/true,ThrottleDisplayNoneAndVisibilityHiddenCrossOriginIframes,UseSkiaRenderer,WebAssemblyLazyCompilation --disable-features=Vulkan --force_high_performance_gpu`, // Performance
'battery': '--enable-features=TurnOffStreamingMediaCachingOnBattery --force_low_power_gpu' // Known to have better battery life for Chromium?
2021-12-21 10:38:18 +00:00
};
const combinePresets = (...keys) => Object.values(keys.reduce((acc, x) => {
for (const cmd of (presets[x] || '').split(' ')) {
if (!cmd) continue;
2021-12-21 10:38:18 +00:00
const [ key, value ] = cmd.split('=');
if (!acc[key]) acc[key] = [key];
acc[key].push(value);
}
2021-12-21 10:38:18 +00:00
return acc;
}, {}));
2021-12-21 10:38:18 +00:00
module.exports = () => {
for (const [ key, ...values ] of combinePresets('base', ...(oaConfig.cmdPreset || 'perf').split(','))) {
app.commandLine.appendSwitch(key.replace('--', ''), values.join(','));
2021-12-21 10:38:18 +00:00
}
}