🌈️ apply a wallpaper based on the weather outside
0

Configure Feed

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

feat: attempt cross-platform compatibility with better config paths

Angel Wang (Jun 21, 2026, 3:27 PM -0600) 648c762e 45ff987e

+48 -15
+2 -1
deno.json
··· 6 6 "apply": "deno run -A apply/index.ts" 7 7 }, 8 8 "imports": { 9 - "@std/assert": "jsr:@std/assert@1" 9 + "@std/assert": "jsr:@std/assert@1", 10 + "@std/path": "jsr:@std/path@^1.1.5" 10 11 }, 11 12 "fmt": { "semiColons": false, "indentWidth": 4, "useTabs": true, "lineWidth": 120 } 12 13 }
+9 -2
deno.lock
··· 10 10 "@std/assert@1.0.19": { 11 11 "integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e", 12 12 "dependencies": [ 13 - "jsr:@std/internal" 13 + "jsr:@std/internal@^1.0.12" 14 14 ] 15 15 }, 16 16 "@std/internal@1.0.14": { 17 17 "integrity": "291516b3d4c35024d6ffbc0a9df5bf4c64116e05b50012cf846710152d2ffdf7" 18 + }, 19 + "@std/path@1.1.5": { 20 + "integrity": "ccea00982ea28c36becaf6e62f855406c76a8c32d462f66f415bbb7d83a271bc", 21 + "dependencies": [ 22 + "jsr:@std/internal@^1.0.14" 23 + ] 18 24 } 19 25 }, 20 26 "npm": { ··· 28 34 }, 29 35 "workspace": { 30 36 "dependencies": [ 31 - "jsr:@std/assert@1" 37 + "jsr:@std/assert@1", 38 + "jsr:@std/path@^1.1.5" 32 39 ], 33 40 "packageJson": { 34 41 "dependencies": [
+37 -12
utils.ts
··· 1 + import * as path from "@std/path" 1 2 import "zx/globals" 2 3 3 - export const configDir = process.env.XDG_CONFIG_HOME 4 - ? `${process.env.XDG_CONFIG_HOME}/rainwall` 5 - : `${os.homedir()}/.config/rainwall` 6 - export const cacheDir = process.env.XDG_CACHE_HOME 7 - ? `${process.env.XDG_CACHE_HOME}/rainwall` 8 - : `${os.homedir()}/.cache/rainwall` 4 + function getConfigPath() { 5 + if (Deno.build.os == "windows") { 6 + return path.fromFileUrl(`file:///${os.homedir}/AppData/Local/rainwall`) 7 + } else if (Deno.build.os == "darwin") { 8 + return path.fromFileUrl(`file:///${os.homedir()}/Library/Preferences/rainwall`) 9 + } else { 10 + return process.env.XDG_CONFIG_HOME 11 + ? path.fromFileUrl(`file:///${process.env.XDG_CONFIG_HOME}/rainwall`) 12 + : path.fromFileUrl(`file:///${os.homedir()}/.config/rainwall`) 13 + } 14 + } 15 + 16 + function getCachePath() { 17 + if (Deno.build.os == "windows") { 18 + return path.fromFileUrl(`file:///${os.homedir}/AppData/Local/Temp/rainwall`) 19 + } else if (Deno.build.os == "darwin") { 20 + return path.fromFileUrl(`file:///${os.homedir()}/Library/Caches/rainwall`) 21 + } else { 22 + return process.env.XDG_CACHE_HOME 23 + ? path.fromFileUrl(`file:///${process.env.XDG_CACHE_HOME}/rainwall`) 24 + : path.fromFileUrl(`file:///${os.homedir()}/.cache/rainwall`) 25 + } 26 + } 27 + 28 + export const configDir = getConfigPath() 29 + 30 + export const cacheDir = getCachePath() 9 31 10 32 if (!fs.statSync(configDir)) { 11 33 fs.mkdirSync(configDir) ··· 22 44 encoding: "utf8", 23 45 }) 24 46 if (stringConfig == undefined) { 25 - console.warn( 47 + console.log( 26 48 `Current config blank, generating a new one... you may need to stop this process and edit the config file.`, 27 49 ) 28 50 config = defaultConfig ··· 31 53 config = JSON.parse(stringConfig) 32 54 } 33 55 } catch (err) { 34 - console.warn( 35 - `Got ${ 36 - (err as Error).message 37 - } when trying to load config, generating a new one... you may need to stop this process and edit the config file.`, 38 - ) 56 + console.warn(chalkWarn( 57 + `Got ${(err as Error).message} when trying to load config, generating a new one... 58 + you may need to stop this process and edit the config file.`, 59 + )) 39 60 config = defaultConfig 40 61 writeDefaultConfig(pathToConfig, defaultConfig) 41 62 } ··· 47 68 await fs.writeFile(`${path}`, JSON.stringify(data, null, 4)) 48 69 console.info(`Generated default config at ${path}!`) 49 70 } 71 + 72 + export const chalkError = chalk.bold.red 73 + export const chalkWarn = chalk.yellow 74 + export const chalkDebug = chalk.gray 50 75 51 76 export function clamp(number: number, min: number, max: number) { 52 77 return Math.max(min, Math.min(number, max))