Skip to content

Commit

Permalink
feat: make lockscreen not replace system files
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 26, 2023
1 parent ddfb730 commit 51bff6f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/playbook/Configuration/tweaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ features:
- tweaks\qol\config-start-menu.yml
- tweaks\qol\config-windows-ink-workspace.yml
- tweaks\qol\disable-background-auto-login.yml
- tweaks\qol\disable-lockscreen.yml
- tweaks\qol\disable-mouse-accel.yml
- tweaks\qol\disable-settings-tips.yml
- tweaks\qol\disable-spell-checking.yml
Expand Down
19 changes: 19 additions & 0 deletions src/playbook/Configuration/tweaks/qol/appearance/atlas-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ actions:
exeDir: true
wait: true

# Set lockscreen
- !cmd:
command: 'NSudoLC.exe -U:E -UseCurrentConsole -Wait powershell.exe -NoP -EP Unrestricted -File "LOCKSCREEN.ps1"'
wait: true
exeDir: true

# Apply theme to current user
- !run:
exe: 'NSudoLC.exe'
Expand All @@ -21,6 +27,19 @@ actions:
- !taskKill: {name: 'control'}
- !taskKill: {name: 'explorer'}

# Disable lockscreen
- !registryValue:
path: 'HKLM\SOFTWARE\Policies\Microsoft\Windows\Personalization'
value: 'NoLockScreen'
data: '1'
type: REG_DWORD
# Disable fun facts, tips, tricks, and more on lockscreen
- !registryValue:
path: 'HKLM\SOFTWARE\Policies\Microsoft\Windows\Personalization'
value: 'LockScreenOverlaysDisabled'
data: '1'
type: REG_DWORD

# Windows theme
- !registryValue:
path: 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize'
Expand Down
10 changes: 0 additions & 10 deletions src/playbook/Configuration/tweaks/qol/disable-lockscreen.yml

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/playbook/Executables/LOCKSCREEN.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Make temporary directory
$tempDir = Join-Path -Path $env:TEMP -ChildPath $([System.IO.Path]::GetRandomFileName())
New-Item $tempDir -ItemType Directory -Force | Out-Null

# Credit: https://superuser.com/a/1343640
$imagePath = "$env:windir\AtlasModules\Wallpapers\lockscreen.png"

$newImagePath = $tempDir + '\' + (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) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
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($newImagePath)) ([Windows.Storage.StorageFile])
AwaitAction ([Windows.System.UserProfile.LockScreen]::SetImageFileAsync($image))

Remove-Item $tempDir -Recurse -Force
Binary file removed src/playbook/Executables/Screen/img100.jpg
Binary file not shown.
4 changes: 4 additions & 0 deletions src/playbook/Executables/THEME.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ for /d %%a in ("%ProgramData%\Microsoft\Windows\SystemData\*") do (
)
)

:: set default lockscreen
:: https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.ControlPanelDisplay::CPL_Personalization_ForceDefaultLockScreen
reg add "HKLM\Software\Policies\Microsoft\Windows\Personalization" /v LockScreenImage /t REG_SZ /d "%windir%\AtlasModules\Wallpapers\lockscreen.png" /f

taskkill /F /IM sihost.exe > nul 2>&1
exit /b

Expand Down

0 comments on commit 51bff6f

Please sign in to comment.