2021-12-21 10:38:18 +00:00
const { app } = require ( 'electron' ) ;
const presets = {
2022-02-12 17:04:21 +00:00
'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
2022-01-19 17:19:17 +00:00
'battery' : '--enable-features=TurnOffStreamingMediaCachingOnBattery --force_low_power_gpu' // Known to have better battery life for Chromium?
2021-12-21 10:38:18 +00:00
} ;
2022-03-09 22:05:40 +00:00
module . exports = ( ) => {
2022-04-22 16:44:20 +00:00
let c = { } ;
for ( const x of ( 'base,' + ( oaConfig . cmdPreset || 'perf' ) ) . split ( ',' ) . reduce ( ( a , x ) => a . concat ( presets [ x ] ? . split ( ' ' ) ) , [ ] ) ) {
2022-04-22 16:47:47 +00:00
if ( ! x ) continue ;
2022-04-22 16:44:20 +00:00
const [ k , v ] = x . split ( '=' ) ;
( c [ k ] = c [ k ] || [ ] ) . push ( v ) ;
}
for ( const k in c ) {
app . commandLine . appendSwitch ( k . replace ( '--' , '' ) , c [ k ] . join ( ',' ) ) ;
2021-12-21 10:38:18 +00:00
}
2022-03-15 17:34:57 +00:00
} ;