-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"daySegment2": 0, | ||
"daySegment4": 1, | ||
"themeMode": 0, | ||
"imagePaths": [ | ||
"C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)][int]$daySegment2, # 0 = Day, 1 = Night | ||
[Parameter(Mandatory=$true)][int]$daySegment4, # -1 = N/A, 0 = Sunrise, 1 = Day, 2 = Sunset, 3 = Night | ||
[Parameter(Mandatory=$true)][bool]$nightMode, # True if night mode is enabled | ||
[Parameter(Mandatory=$false)][string]$imagePath # Path to current wallpaper image | ||
) | ||
# To test with sample event, run: cat SampleEvent.json | .\SampleScript.ps1 | ||
$event = $Input | ConvertFrom-Json | ||
Check warning Code scanning / PSScriptAnalyzer The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name. Warning
The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
|
||
|
||
Add-Type -AssemblyName PresentationCore,PresentationFramework | ||
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | ||
[System.Windows.MessageBox]::Show([string]$daySegment2 + ' ' + [string]$daySegment4 + ' ' + [string]$nightMode + ' ' + $imagePath) | ||
[System.Windows.MessageBox]::Show(($event | Format-List | Out-String), "WinDynamicDesktop") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)][int]$daySegment2, # 0 = Day, 1 = Night | ||
[Parameter(Mandatory=$true)][int]$daySegment4, # -1 = N/A, 0 = Sunrise, 1 = Day, 2 = Sunset, 3 = Night | ||
[Parameter(Mandatory=$true)][bool]$nightMode, # True if night mode is enabled | ||
[Parameter(Mandatory=$false)][string]$imagePath # Path to current wallpaper image | ||
) | ||
$event = $Input | ConvertFrom-Json | ||
Check warning Code scanning / PSScriptAnalyzer The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name. Warning
The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
|
||
|
||
If (-Not ($PSBoundParameters.ContainsKey("imagePath"))) { | ||
Break | ||
} | ||
|
||
If (Test-Path "~\AppData\Local\Microsoft\Edge\User Data\Default") { | ||
Copy-Item $imagePath "~\AppData\Local\Microsoft\Edge\User Data\Default\edge_background.jpg" | ||
If ($event.imagePaths -And (Test-Path "~\AppData\Local\Microsoft\Edge\User Data\Default")) { | ||
Copy-Item $event.imagePaths[0] "~\AppData\Local\Microsoft\Edge\User Data\Default\edge_background.jpg" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)][int]$daySegment2, # 0 = Day, 1 = Night | ||
[Parameter(Mandatory=$true)][int]$daySegment4, # -1 = N/A, 0 = Sunrise, 1 = Day, 2 = Sunset, 3 = Night | ||
[Parameter(Mandatory=$true)][bool]$nightMode, # True if night mode is enabled | ||
[Parameter(Mandatory=$false)][string]$imagePath # Path to current wallpaper image | ||
) | ||
$event = $Input | ConvertFrom-Json | ||
Check warning Code scanning / PSScriptAnalyzer The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name. Warning
The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
|
||
|
||
$registryPath = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main" | ||
$dwordValue = If ($nightMode) {1} Else {$daySegment2} | ||
$dwordValue = If ($event.themeMode -Eq 0) {$event.daySegment2} Else {$event.themeMode - 1} | ||
|
||
if ( Test-Path $registryPath ) | ||
if (Test-Path $registryPath) | ||
{ | ||
New-ItemProperty -Path $registryPath -Name "Theme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)][int]$daySegment2, # 0 = Day, 1 = Night | ||
[Parameter(Mandatory=$true)][int]$daySegment4, # -1 = N/A, 0 = Sunrise, 1 = Day, 2 = Sunset, 3 = Night | ||
[Parameter(Mandatory=$true)][bool]$nightMode, # True if night mode is enabled | ||
[Parameter(Mandatory=$false)][string]$imagePath # Path to current wallpaper image | ||
) | ||
$event = $Input | ConvertFrom-Json | ||
Check warning Code scanning / PSScriptAnalyzer The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name. Warning
The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
|
||
|
||
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" | ||
$dwordValue = If ($nightMode) {0} Else {1 - $daySegment2} | ||
$dwordValue = 1 - (If ($event.themeMode -Eq 0) {$event.daySegment2} Else {$event.themeMode - 1}) | ||
|
||
if ( Test-Path $registryPath ) | ||
if (Test-Path $registryPath) | ||
{ | ||
New-ItemProperty -Path $registryPath -Name "AppsUseLightTheme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
param ( | ||
[Parameter(Mandatory=$true)][int]$daySegment2, # 0 = Day, 1 = Night | ||
[Parameter(Mandatory=$true)][int]$daySegment4, # -1 = N/A, 0 = Sunrise, 1 = Day, 2 = Sunset, 3 = Night | ||
[Parameter(Mandatory=$true)][bool]$nightMode, # True if night mode is enabled | ||
[Parameter(Mandatory=$false)][string]$imagePath # Path to current wallpaper image | ||
) | ||
$event = $Input | ConvertFrom-Json | ||
Check warning Code scanning / PSScriptAnalyzer The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name. Warning
The Variable 'event' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
|
||
|
||
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" | ||
$dwordValue = If ($nightMode) {0} Else {1 - $daySegment2} | ||
$dwordValue = 1 - (If ($event.themeMode -Eq 0) {$event.daySegment2} Else {$event.themeMode - 1}) | ||
|
||
if ( Test-Path $registryPath ) | ||
if (Test-Path $registryPath) | ||
{ | ||
New-ItemProperty -Path $registryPath -Name "SystemUsesLightTheme" -Value $dwordValue -PropertyType DWORD -Force | Out-Null | ||
} |