fix: reliable accent color in all profiles + BackInfo background

- 04 profile: write AccentPalette (REG_BINARY, 8 shades derived from #223B47)
  alongside AccentColor/AccentColorMenu. Without AccentPalette, Win11 ignores
  the custom accent on Start/taskbar and falls back to the default - the cause
  of "colors not applied everywhere". Also mirror the full theme + accent into
  HKU\.DEFAULT (lock/welcome screen, system context) on top of the Default hive
  and current user, so all profiles match. Mode stays Custom (dark system,
  light apps); ColorPrevalence on for Start/taskbar and title bars/borders.
- BackInfo.ini: BackgroundColor 4668194 -> 2243399. BackInfo reads the value as
  0xRRGGBB (RGB), not COLORREF/BGR, so #223B47 = 0x223B47 = 2243399; the BGR
  value rendered with red/blue swapped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
X9 Dev 2026-06-02 10:39:57 +02:00
parent 603fba5372
commit 4d08d0cd46
2 changed files with 64 additions and 3 deletions

View file

@ -56,8 +56,9 @@
;;
[General]
; #223B47 in COLORREF (0x00BBGGRR): R=34 G=59 B=71 = 71*65536 + 59*256 + 34 = 4668194
BackgroundColor = 4668194
; #223B47 read as 0xRRGGBB decimal: BackInfo uses RGB order here (NOT COLORREF/BGR),
; so 0x223B47 = 2243399. The previous BGR value (4668194) rendered with R/B swapped.
BackgroundColor = 2243399
; AutoBackground=0: do NOT read live desktop color - unreliable during deployment
; (live session may not yet reflect the registry background color change)
AutoBackground = 0

View file

@ -104,8 +104,35 @@ function Set-ProfileReg {
}
}
# Accent color #223B47 stored as ABGR DWORD: 0xFF473B22
# Accent color #223B47 (R=34 G=59 B=71) stored as ABGR DWORD: 0xFF473B22
$AccentColorABGR = 0xFF473B22
$AccentR = 0x22; $AccentG = 0x3B; $AccentB = 0x47
# Build the 8-shade AccentPalette that Settings writes under Explorer\Accent.
# Without it Win11 ignores the custom accent on Start/taskbar and falls back to
# the default - the root cause of "colors not applied everywhere". Layout:
# Light3, Light2, Light1, Accent(base, index 3), Dark1..Dark4. Each entry RGBA.
function Get-AccentPalette {
param([int]$R, [int]$G, [int]$B)
$tints = @(0.70, 0.45, 0.20) # light3 (lightest) -> light1
$shades = @(0.25, 0.45, 0.65, 0.85) # dark1 -> dark4
$bytes = New-Object System.Collections.Generic.List[byte]
foreach ($t in $tints) {
$bytes.Add([byte][math]::Round($R + (255 - $R) * $t))
$bytes.Add([byte][math]::Round($G + (255 - $G) * $t))
$bytes.Add([byte][math]::Round($B + (255 - $B) * $t))
$bytes.Add(0xFF)
}
$bytes.Add([byte]$R); $bytes.Add([byte]$G); $bytes.Add([byte]$B); $bytes.Add(0xFF) # base accent
foreach ($s in $shades) {
$bytes.Add([byte][math]::Round($R * (1 - $s)))
$bytes.Add([byte][math]::Round($G * (1 - $s)))
$bytes.Add([byte][math]::Round($B * (1 - $s)))
$bytes.Add(0xFF)
}
return ,([byte[]]$bytes.ToArray())
}
$AccentPalette = Get-AccentPalette $AccentR $AccentG $AccentB
# -----------------------------------------------------------------------
# Load Default profile hive
@ -331,6 +358,11 @@ $pinList
Set-ProfileReg -SubKey "Software\Microsoft\Windows\CurrentVersion\Explorer\Accent" `
-Name "StartColorMenu" -Value $AccentColorABGR -Type "DWord"
# AccentPalette - required for Win11 to actually honor the accent on Start
# and taskbar (without it the custom color is dropped for the default).
Set-ProfileReg -SubKey "Software\Microsoft\Windows\CurrentVersion\Explorer\Accent" `
-Name "AccentPalette" -Value $AccentPalette -Type "Binary"
# Wallpaper - solid color #223B47 (BackInfo overwrites on logon)
Set-ProfileReg -SubKey "Control Panel\Colors" `
-Name "Background" -Value "34 59 71" -Type "String"
@ -341,6 +373,34 @@ $pinList
Set-ProfileReg -SubKey "Control Panel\Desktop" `
-Name "TileWallpaper" -Value "0" -Type "String"
# Mirror the theme + accent into HKU\.DEFAULT so the lock/welcome screen and
# system-context UI use the same branding (covers "all profiles", not just
# newly created users which inherit from the Default hive above).
$defaultColors = @(
@{ Key="Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; Name="SystemUsesLightTheme"; Val=0; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; Name="AppsUseLightTheme"; Val=1; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; Name="ColorPrevalence"; Val=1; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; Name="EnableTransparency"; Val=0; Type="DWord" },
@{ Key="Software\Microsoft\Windows\DWM"; Name="AccentColor"; Val=$AccentColorABGR; Type="DWord" },
@{ Key="Software\Microsoft\Windows\DWM"; Name="ColorizationColor"; Val=$AccentColorABGR; Type="DWord" },
@{ Key="Software\Microsoft\Windows\DWM"; Name="ColorizationAfterglow";Val=$AccentColorABGR; Type="DWord" },
@{ Key="Software\Microsoft\Windows\DWM"; Name="ColorPrevalence"; Val=1; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Explorer\Accent"; Name="AccentColorMenu"; Val=$AccentColorABGR; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Explorer\Accent"; Name="StartColorMenu"; Val=$AccentColorABGR; Type="DWord" },
@{ Key="Software\Microsoft\Windows\CurrentVersion\Explorer\Accent"; Name="AccentPalette"; Val=$AccentPalette; Type="Binary" }
)
foreach ($c in $defaultColors) {
$cp = "Registry::HKU\.DEFAULT\$($c.Key)"
try {
if (-not (Test-Path $cp)) { New-Item -Path $cp -Force -ErrorAction Stop | Out-Null }
Set-ItemProperty -Path $cp -Name $c.Name -Value $c.Val -Type $c.Type -Force -ErrorAction Stop
}
catch {
Write-Log " .DEFAULT color $($c.Key)\$($c.Name) failed - $_" -Level WARN
}
}
Write-Log " Theme/accent mirrored to HKU\.DEFAULT" -Level OK
# ===================================================================
# KEYBOARD LAYOUTS - Czech primary, US secondary
# ===================================================================