Skip to content

Commit e4d3052

Browse files
authored
feat: detect reverted tweaks on startup (ChrisTitusTech#4582)
Co-authored-by: vyas-devgna <vyas-devgna@users.noreply.github.com>
1 parent 78593cc commit e4d3052

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

functions/public/Invoke-WPFtweaksbutton.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ function Invoke-WPFtweaksbutton {
8282
Write-Host "================================="
8383
Write-Host "-- Tweaks are Finished ---"
8484
Write-Host "================================="
85+
@($tweaks | Where-Object { $sync.configs.tweaks.$_.registry -or $sync.configs.tweaks.$_.service }) | ConvertTo-Json | Out-File "$env:LocalAppData\winutil\lastrun.json" -Force
8586
}
8687
}

scripts/main.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,17 @@ $sync["Form"].Add_ContentRendered({
400400
Invoke-WPFTab "WPFTab1BT" # Default to install tab
401401
}
402402

403+
if (-not $PARAM_CONFIG -and (Test-Path "$winutildir\lastrun.json")) {
404+
try {
405+
$drifted = @(Get-Content "$winutildir\lastrun.json" | ConvertFrom-Json | Where-Object { $_ -notin (Invoke-WinUtilCurrentSystem -CheckBox "tweaks") })
406+
if ($drifted.Count -gt 0 -and [System.Windows.MessageBox]::Show("$($drifted.Count) tweak(s) were reverted since last run. Re-select them?", "Winutil", "YesNo", "Question") -eq "Yes") {
407+
Update-WinUtilSelections -flatJson $drifted
408+
Reset-WPFCheckBoxes -doToggles $false
409+
Invoke-WPFTab "WPFTab2BT"
410+
}
411+
} catch {}
412+
}
413+
403414
$sync["Form"].Focus()
404415

405416
if ($PARAM_CONFIG -and -not [string]::IsNullOrWhiteSpace($PARAM_CONFIG)) {

0 commit comments

Comments
 (0)