diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
| commit | 19120d4f9761c67d99ed1ce3da6084b83f5a49c9 (patch) | |
| tree | f234cad1bdad88114a63c9702144da487024967a /.config/ags/service/weather.ts | |
| parent | 5928998af5404ae2be84c6cecc10ebf84bd3f3ed (diff) | |
| download | dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.tar.gz dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.zip | |
Linux-specific dotfiles
Diffstat (limited to '.config/ags/service/weather.ts')
| -rw-r--r-- | .config/ags/service/weather.ts | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/.config/ags/service/weather.ts b/.config/ags/service/weather.ts deleted file mode 100644 index 14f2df2..0000000 --- a/.config/ags/service/weather.ts +++ /dev/null @@ -1,59 +0,0 @@ -import options from "options" - -const { interval, key, cities, unit } = options.datemenu.weather - -class Weather extends Service { - static { - Service.register(this, {}, { - "forecasts": ["jsobject"], - }) - } - - #forecasts: Forecast[] = [] - get forecasts() { return this.#forecasts } - - async #fetch(placeid: number) { - const url = "https://api.openweathermap.org/data/2.5/forecast" - const res = await Utils.fetch(url, { - params: { - id: placeid, - appid: key.value, - untis: unit.value, - }, - }) - return await res.json() - } - - constructor() { - super() - if (!key.value) - return this - - Utils.interval(interval.value, () => { - Promise.all(cities.value.map(this.#fetch)).then(forecasts => { - this.#forecasts = forecasts as Forecast[] - this.changed("forecasts") - }) - }) - } -} - -export default new Weather - -type Forecast = { - city: { - name: string, - } - list: Array<{ - dt: number - main: { - temp: number - feels_like: number - }, - weather: Array<{ - main: string, - description: string, - icon: string, - }> - }> -} |
