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-03-15 17:34:57 +00:00
for ( const [ key , ... values ] of Object . values ( [ 'base' , ... ( oaConfig . cmdPreset || 'perf' ) . split ( ',' ) ] . reduce ( ( acc , x ) => {
for ( const cmd of ( presets [ x ] || '' ) . split ( ' ' ) ) {
if ( ! cmd ) continue ;
const [ key , value ] = cmd . split ( '=' ) ;
if ( ! acc [ key ] ) acc [ key ] = [ key ] ;
acc [ key ] . push ( value ) ;
}
return acc ;
} , { } ) ) ) {
2022-03-09 22:05:40 +00:00
app . commandLine . appendSwitch ( key . replace ( '--' , '' ) , values . join ( ',' ) ) ;
2021-12-21 10:38:18 +00:00
}
2022-03-15 17:34:57 +00:00
} ;