2023-07-27 16:06:41 -05:00
|
|
|
Function Invoke-WinUtilDarkMode {
|
2023-10-19 17:12:55 -05:00
|
|
|
<#
|
|
|
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Enables/Disables Dark Mode
|
|
|
|
|
|
|
|
|
|
.PARAMETER DarkMoveEnabled
|
|
|
|
|
Indicates the current dark mode state
|
|
|
|
|
|
2023-03-07 12:28:00 -08:00
|
|
|
#>
|
|
|
|
|
Param($DarkMoveEnabled)
|
2024-08-06 23:35:17 +03:00
|
|
|
try {
|
|
|
|
|
if ($DarkMoveEnabled -eq $false) {
|
2023-03-07 12:28:00 -08:00
|
|
|
Write-Host "Enabling Dark Mode"
|
|
|
|
|
$DarkMoveValue = 0
|
2024-08-06 23:35:17 +03:00
|
|
|
} else {
|
2023-03-07 12:28:00 -08:00
|
|
|
Write-Host "Disabling Dark Mode"
|
|
|
|
|
$DarkMoveValue = 1
|
|
|
|
|
}
|
2023-10-19 17:12:55 -05:00
|
|
|
|
2023-11-14 15:45:48 -06:00
|
|
|
$Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
|
|
|
|
|
Set-ItemProperty -Path $Path -Name AppsUseLightTheme -Value $DarkMoveValue
|
|
|
|
|
Set-ItemProperty -Path $Path -Name SystemUsesLightTheme -Value $DarkMoveValue
|
2024-09-20 16:01:39 +02:00
|
|
|
Invoke-WinUtilExplorerRefresh
|
2024-09-21 17:01:02 +02:00
|
|
|
# Update Winutil Theme if the Theme Button shows the Icon for Auto
|
|
|
|
|
if ($sync.ThemeButton.Content -eq [char]0xF08C) {
|
|
|
|
|
Invoke-WinutilThemeChange -theme "Auto"
|
|
|
|
|
}
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch [System.Security.SecurityException] {
|
2023-03-07 12:28:00 -08:00
|
|
|
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch [System.Management.Automation.ItemNotFoundException] {
|
2023-03-07 12:28:00 -08:00
|
|
|
Write-Warning $psitem.Exception.ErrorRecord
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch {
|
2023-03-07 12:28:00 -08:00
|
|
|
Write-Warning "Unable to set $Name due to unhandled exception"
|
|
|
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
|
|
|
}
|
2024-08-06 23:35:17 +03:00
|
|
|
}
|