🌈️ apply a wallpaper based on the weather outside
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(apply): fix Windows script

Angel Wang (Jun 23, 2026, 1:56 AM -0600) 60191fb6 53a0dae2

+30 -23
+18 -21
src/utils.ts
··· 39 39 40 40 if (!fs.statSync(windowsApplyScriptPath, { throwIfNoEntry: false })) { 41 41 // C# in TypeScript. who would've thought 42 - // uiAction: SPI_SetDeskWallpaper = 0x0014 = 20 43 - // uiParam: unused = 0 44 - // pvParam: path to the image 45 - // fWinIni: SPIF_SENDCHANGE (update user profile + broadcast setting change) = 0x02 = 2 46 - 47 42 const command = ` 48 - $imagePath = $args[0] 49 - $code = @' 50 - using System.Runtime.InteropServices; 51 - namespace Win32 { 52 - public class Wallpaper { 53 - [DllImport("user32.dll", CharSet=CharSet.Auto)] 54 - static extern int SystemParametersInfoA(int uiAction, int uiParam, string pvParam, int fWinIni); 55 - 56 - public static void SetWallpaper(string imagePath){ 57 - SystemParametersInfo(20, 0, imagePath, 2); 58 - } 59 - } 60 - } 61 - '@ 43 + $imagePath = $args[0] 44 + $setwallpapersrc = @" 45 + using System.Runtime.InteropServices; 46 + public class wallpaper { 47 + public const int SetDesktopWallpaper = 20; 48 + public const int UpdateIniFile = 0x01; 49 + public const int SendWinIniChange = 0x02; 62 50 63 - add-type $code 64 - [Win32.Wallpaper]::SetWallpaper($imagePath) 51 + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] 52 + private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni); 53 + 54 + public static void SetWallpaper (string path) { 55 + SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange); 56 + } 57 + } 58 + "@ 59 + Add-Type -TypeDefinition $setwallpapersrc 60 + 61 + [wallpaper]::SetWallpaper("$imagePath") 65 62 ` 66 63 await fs.writeFile(windowsApplyScriptPath, command) 67 64 console.info(`Wrote Windows wallpaper apply script at ${windowsApplyScriptPath}!`)
+12 -2
src/apply/index.ts
··· 1 1 import type { ImageAnalysisData } from "../analyze/analysis.ts" 2 - import { applyConfigPath, cachePath, chalkDebug, loadConfig, map, mapEaseOutExp, mapEaseOutQuint, windowsApplyScriptPath } from "../utils.ts" 2 + import { 3 + applyConfigPath, 4 + cachePath, 5 + chalkDebug, 6 + loadConfig, 7 + map, 8 + mapEaseOutExp, 9 + mapEaseOutQuint, 10 + windowsApplyScriptPath, 11 + } from "../utils.ts" 3 12 import { type ApplicationConfig, defaultConfig, findMatchingImages, getOpenMeteoData } from "./application.ts" 4 13 import * as SunCalc from "suncalc" 5 14 import "zx/globals" ··· 83 92 if (Deno.build.os != "windows") { 84 93 await $`eval ${config.applyWallpaperCommand.replace("%s", targetImage.path)}` 85 94 } else { 86 - await $`pwsh ${windowsApplyScriptPath}` 95 + const command = new Deno.Command(`pwsh`, { args: [ windowsApplyScriptPath, targetImage.path ], stdout: "piped" } ) 96 + command.spawn() 87 97 } 88 98 console.info(`Success! Enjoy :)`)