From 29f76df3dd090b39054b02ba93ce2acfaf0d03ba Mon Sep 17 00:00:00 2001 From: he3als <65787561+he3als@users.noreply.github.com> Date: Tue, 7 Nov 2023 22:36:09 +0000 Subject: [PATCH] fix: lockscreen --- .../tweaks/qol/appearance/atlas-theme.yml | 2 +- src/playbook/Executables/LOCKSCREEN.ps1 | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/playbook/Configuration/tweaks/qol/appearance/atlas-theme.yml b/src/playbook/Configuration/tweaks/qol/appearance/atlas-theme.yml index 0141dbd396..ea4014486f 100644 --- a/src/playbook/Configuration/tweaks/qol/appearance/atlas-theme.yml +++ b/src/playbook/Configuration/tweaks/qol/appearance/atlas-theme.yml @@ -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} diff --git a/src/playbook/Executables/LOCKSCREEN.ps1 b/src/playbook/Executables/LOCKSCREEN.ps1 index d078c02dad..67bb741bea 100644 --- a/src/playbook/Executables/LOCKSCREEN.ps1 +++ b/src/playbook/Executables/LOCKSCREEN.ps1 @@ -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)) \ No newline at end of file +$image = Await ([Windows.Storage.StorageFile]::GetFileFromPathAsync($newImagePath)) ([Windows.Storage.StorageFile]) +AwaitAction ([Windows.System.UserProfile.LockScreen]::SetImageFileAsync($image)) +Remove-Item $newImagePath \ No newline at end of file