Skip to content

Commit

Permalink
fix: lockscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Nov 7, 2023
1 parent d038374 commit 29f76df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actions:
# Set lockscreen
- !run:
exe: 'powershell.exe'
args: '-NoP -EP Unrestricted -File "LOCKSCREEN.ps1"'
args: '-NoP -EP Unrestricted & """LOCKSCREEN.ps1"""'
exeDir: true
runas: currentUserElevated
- !taskKill: {name: 'SystemSettings', ignoreErrors: true}
Expand Down
11 changes: 6 additions & 5 deletions src/playbook/Executables/LOCKSCREEN.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Credit: https://superuser.com/a/1343640
$imagePath = "$env:windir\AtlasModules\Wallpapers\lockscreen.png"

$newImagePath = $(Split-Path $imagePath) + '\' + (New-Guid).Guid + [System.IO.Path]::GetExtension($imagePath)
$newImagePath = [System.IO.Path]::GetDirectoryName($imagePath) + '\' + (New-Guid).Guid + [System.IO.Path]::GetExtension($imagePath)
Copy-Item $imagePath $newImagePath
[Windows.System.UserProfile.LockScreen,Windows.System.UserProfile,ContentType=WindowsRuntime] | Out-Null
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
function Await($WinRtTask, $ResultType) {
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
function AwaitAction($WinRtAction) {
Function AwaitAction($WinRtAction) {
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
$netTask = $asTask.Invoke($null, @($WinRtAction))
$netTask.Wait(-1) | Out-Null
}
[Windows.Storage.StorageFile,Windows.Storage,ContentType=WindowsRuntime] | Out-Null
$image = Await ([Windows.Storage.StorageFile]::GetFileFromPathAsync("$env:windir\AtlasModules\Wallpapers\lockscreen.png")) ([Windows.Storage.StorageFile])
AwaitAction ([Windows.System.UserProfile.LockScreen]::SetImageFileAsync($image))
$image = Await ([Windows.Storage.StorageFile]::GetFileFromPathAsync($newImagePath)) ([Windows.Storage.StorageFile])
AwaitAction ([Windows.System.UserProfile.LockScreen]::SetImageFileAsync($image))
Remove-Item $newImagePath

0 comments on commit 29f76df

Please sign in to comment.