Skip to content

Commit b5354fa

Browse files
committed
fix: set wallpaper failed
Since the path can be different for each wallpaper, now, full path is registered in the list instead of the folder name only.
1 parent 0e1b388 commit b5354fa

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Set random Wallpaper.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ function UpdateList {
278278

279279
foreach ($path in $WallpapersPaths) {
280280

281+
Write-Debug "Path: $path"
282+
281283
if (Test-Path -Path $path -PathType Container) {
282284
# Browse each Wallpapers child folder (non-recursively)
283285
Get-ChildItem -Path $path -Directory | ForEach-Object {
284-
$CurrentFolder = $_.Name
286+
$CurrentFolder = $_.FullName
285287
# Path to the LivelyInfo.json file in the current folder
286288
$jsonFile = Join-Path -Path $_.FullName -ChildPath 'LivelyInfo.json'
287289

@@ -402,12 +404,16 @@ $SetRandom = {
402404
$null = New-ItemProperty -Path "HKCU:\Environment" -Name $EnvPrevName -Value $randomWallpaper.Folder -PropertyType String -Force
403405
}
404406
catch {
405-
TerminateWithError -errorMessage "`"$randomWallpaper.Folder`" failed to be registered as the user environment variable `"$EnvPrevName`""
407+
TerminateWithError -errorMessage "`"$($randomWallpaper.Folder)`" failed to be registered as the user environment variable `"$EnvPrevName`""
408+
}
409+
410+
if (-not (Test-Path $randomWallpaper.Folder -PathType Container)) {
411+
TerminateWithError -errorMessage "`"$($randomWallpaper.Folder)`" does not exist. You need to use -UpdateList."
406412
}
407413

408-
$randomWallpaperPath = (Join-Path -Path $LibraryPath -ChildPath $randomWallpaper.Folder)
414+
& $LivelyBin setwp --file "$($randomWallpaper.Folder)"
409415

410-
& $LivelyBin setwp --file "$randomWallpaperPath"
416+
Write-Debug "$LivelyBin setwp --file `"$($randomWallpaper.Folder)`""
411417

412418
Write-Host "`nNew wallapaper set: " -NoNewline
413419
Write-Host "$($randomWallpaper.Title)" -ForegroundColor Green -NoNewline

0 commit comments

Comments
 (0)