From 0ede448f44f4c195a89bfbc2fd8d7a634a137f05 Mon Sep 17 00:00:00 2001 From: rogier Date: Thu, 13 Mar 2025 10:58:52 +0100 Subject: [PATCH] Add background.cmd --- background.cmd | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 background.cmd diff --git a/background.cmd b/background.cmd new file mode 100644 index 0000000..1bb460b --- /dev/null +++ b/background.cmd @@ -0,0 +1,43 @@ +# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B + +# URL of the image +$imageUrl = "https://git.hibbit.net/Huracan/wallpaper/raw/commit/33024a144d2d891fc55c5bcc3332fe0d88b6ffb6/huracan.jpg" + +# Create temp directory if it doesn't exist +$tempDir = "$env:TEMP\wallpaper" +if (-not (Test-Path $tempDir)) { + New-Item -ItemType Directory -Path $tempDir -Force | Out-Null +} + +# Download the image +$wallpaperPath = "$tempDir\background.jpg" +Write-Host "Downloading wallpaper..." -ForegroundColor Yellow +try { + Invoke-WebRequest -Uri $imageUrl -OutFile $wallpaperPath -TimeoutSec 60 + Write-Host "Download complete!" -ForegroundColor Green +} catch { + Write-Error "Failed to download wallpaper: $_" + exit 1 +} + +# Set the wallpaper +try { + $code = @' + using System.Runtime.InteropServices; + public class Wallpaper { + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); + } +'@ + + Add-Type -TypeDefinition $code + $SPI_SETDESKWALLPAPER = 0x0014 + $SPIF_UPDATEINIFILE = 0x01 + $SPIF_SENDCHANGE = 0x02 + + [Wallpaper]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $wallpaperPath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) + Write-Host "Wallpaper set successfully!" -ForegroundColor Green +} catch { + Write-Error "Failed to set wallpaper: $_" + exit 1 +}