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
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
2022-03-09 22:05:40 +00:00
const [ key , value ] = cmd . split ( '=' ) ;
2022-01-13 13:42:04 +00:00
2022-03-09 22:05:40 +00:00
if ( ! acc [ key ] ) acc [ key ] = [ key ] ;
acc [ key ] . push ( value ) ;
}
2021-12-21 10:38:18 +00:00
2022-03-09 22:05:40 +00:00
return acc ;
} , { } ) ) ;
2022-02-01 20:35:59 +00:00
2021-12-21 10:38:18 +00:00
2022-03-09 22:05:40 +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
}
2022-01-13 13:42:04 +00:00
}