mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-09-06 19:25:47 -05:00
Compare commits
3 Commits
a93d44a6dc
...
feff1078d8
Author | SHA1 | Date | |
---|---|---|---|
feff1078d8 | |||
a4fccd3c85 | |||
5c2d5fae1e |
@ -3310,10 +3310,14 @@
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
"Invoke-WinUtilExplorerRefresh"
|
||||
"
|
||||
Invoke-WinUtilExplorerRefresh
|
||||
"
|
||||
],
|
||||
"UndoScript": [
|
||||
"Invoke-WinUtilExplorerRefresh"
|
||||
"
|
||||
Invoke-WinUtilExplorerRefresh
|
||||
"
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/DarkMode"
|
||||
},
|
||||
|
@ -16,23 +16,35 @@ Function Get-WinUtilToggleStatus {
|
||||
|
||||
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
|
||||
|
||||
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
||||
$null = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
||||
write-host "Created HKU drive"
|
||||
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
|
||||
Write-Host "HKU drive created successfully" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed to create HKU drive"
|
||||
}
|
||||
}
|
||||
|
||||
if ($ToggleSwitchReg) {
|
||||
$count = 0
|
||||
|
||||
foreach ($regentry in $ToggleSwitchReg) {
|
||||
$regstate = (Get-ItemProperty -path $($regentry.Path)).$($regentry.Name)
|
||||
write-host "Checking $($regentry.path)"
|
||||
$regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name)
|
||||
if ($regstate -eq $regentry.Value) {
|
||||
$count += 1
|
||||
write-host "$($regentry.Name) is true (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" -ForegroundColor Green
|
||||
} else {
|
||||
write-debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
||||
write-host "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
||||
}
|
||||
}
|
||||
|
||||
if ($count -eq $ToggleSwitchReg.Count) {
|
||||
write-debug "$($ToggleSwitchReg.Name) is true (count: $count)"
|
||||
write-host "$($ToggleSwitchReg.Name) is true (count: $count)" -ForegroundColor Green
|
||||
return $true
|
||||
} else {
|
||||
write-debug "$($ToggleSwitchReg.Name) is false (count: $count)"
|
||||
write-host "$($ToggleSwitchReg.Name) is false (count: $count)"
|
||||
return $false
|
||||
}
|
||||
} else {
|
||||
|
@ -1,31 +0,0 @@
|
||||
function Invoke-WinUtilNumLock {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Disables/Enables NumLock on startup
|
||||
.PARAMETER Enabled
|
||||
Indicates whether to enable or disable Numlock on startup
|
||||
#>
|
||||
Param($Enabled)
|
||||
try {
|
||||
if ($Enabled -eq $false) {
|
||||
Write-Host "Enabling Numlock on startup"
|
||||
$value = 2
|
||||
} else {
|
||||
Write-Host "Disabling Numlock on startup"
|
||||
$value = 0
|
||||
}
|
||||
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
||||
$HKUPath = "HKU:\.Default\Control Panel\Keyboard"
|
||||
$HKCUPath = "HKCU:\Control Panel\Keyboard"
|
||||
Set-ItemProperty -Path $HKUPath -Name InitialKeyboardIndicators -Value $value
|
||||
Set-ItemProperty -Path $HKCUPath -Name InitialKeyboardIndicators -Value $value
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
} catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
} catch {
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
@ -77,6 +77,15 @@ function Invoke-WinUtilTweaks {
|
||||
if($sync.configs.tweaks.$CheckBox.registry) {
|
||||
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
||||
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
|
||||
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
||||
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
||||
write-host "Created HKU drive"
|
||||
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
|
||||
Write-Host "HKU drive created successfully"
|
||||
} else {
|
||||
Write-Host "Failed to create HKU drive"
|
||||
}
|
||||
}
|
||||
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,13 @@ function Invoke-WPFUIElements {
|
||||
|
||||
$sync[$entryInfo.Name] = $checkBox
|
||||
|
||||
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $entryInfo.Name
|
||||
$sync[$entryInfo.Name].IsChecked = (Get-WinUtilToggleStatus $entryInfo.Name)
|
||||
|
||||
if ($sync[$entryInfo.Name].IsChecked) {
|
||||
write-host "$($entryInfo.Name) is checked" -ForegroundColor Blue
|
||||
} else {
|
||||
write-host "$($entryInfo.Name) is not checked" -ForegroundColor Red
|
||||
}
|
||||
|
||||
$sync[$entryInfo.Name].Add_Checked({
|
||||
[System.Object]$Sender = $args[0]
|
||||
|
Reference in New Issue
Block a user