From 43130b46808c7be43dc52bebc14c7b74553e5546 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Wed, 8 Feb 2023 21:32:29 +0100 Subject: [PATCH] :wrench: Tweak migration code --- src/migrate.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/migrate.js b/src/migrate.js index 8b56111..382b535 100644 --- a/src/migrate.js +++ b/src/migrate.js @@ -24,13 +24,22 @@ function migrate() { .then(r => { utils.debug('Starting Burn-My-Windows profile migration!'); - // The default value of this is false, so if it is not present, only normal windows - // were affected. - const onlyNormalWindows = !r.includes('destroy-dialogs=true'); - if (onlyNormalWindows) { + // The default value of this is false, so not-present is equal to false. + const destroyDialogs = r.includes('destroy-dialogs=true'); + if (!destroyDialogs) { utils.debug('Only normal windows will be burned by the new profile(s).'); - } else { - utils.debug('Normal windows and dialogs will be burned by the new profile(s).'); + } + + // The default value of this is false, so not-present is equal to false. + const disableOnBattery = r.includes('disable-on-battery=true'); + if (disableOnBattery) { + utils.debug('The new profile(s) will not be active on battery.'); + } + + // The default value of this is false, so not-present is equal to false. + const disableOnPowerSave = r.includes('disable-on-power-save=true'); + if (disableOnPowerSave) { + utils.debug('The new profile(s) will not be active in power-save mode.'); } // Remove some unnecessary lines. @@ -38,6 +47,8 @@ function migrate() { r = r.replace(/^test-mode=.*\n?/gm, ''); r = r.replace(/^last-version=.*\n?/gm, ''); r = r.replace(/^destroy-dialogs=.*\n?/gm, ''); + r = r.replace(/^disable-on-battery=.*\n?/gm, ''); + r = r.replace(/^disable-on-power-save=.*\n?/gm, ''); r = r.replace(/^.*-preview-.*\n?/gm, ''); r = r.replace('[/]\n', ''); r = r.trim(); @@ -81,10 +92,19 @@ function migrate() { const profile = lines.filter(l => !l.includes('-close-effect=') && !l.includes('-open-effect=')); profile.unshift('[burn-my-windows-profile]'); - if (onlyNormalWindows) { + + if (!destroyDialogs) { profile.push('profile-window-type=1'); } + if (disableOnBattery) { + profile.push('profile-power-mode=2'); + } + + if (disableOnPowerSave) { + profile.push('profile-power-profile=5'); + } + if (numProfiles == 1) { openEffects.forEach(e => profile.push(e + '-enable-effect=true')); if (!openEffects.includes('fire')) {