From 9fa4194b43a60dbc40996446b247259c68c0ccbb Mon Sep 17 00:00:00 2001 From: ferrreo Date: Sun, 20 Aug 2023 19:33:37 +0100 Subject: [PATCH] Update weather --- pika-hyprland-settings/debian/changelog | 6 ++++++ .../etc/skel/.config/ags/widgets/weather.js | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pika-hyprland-settings/debian/changelog b/pika-hyprland-settings/debian/changelog index b28d7c3..803d7f0 100644 --- a/pika-hyprland-settings/debian/changelog +++ b/pika-hyprland-settings/debian/changelog @@ -1,3 +1,9 @@ +pika-hyprland-settings (1.1.2-99pika1) lunar; urgency=medium + + * Fix weather + + -- ferrreo Sat, 01 Oct 2022 14:50:00 +0300 + pika-hyprland-settings (1.1.1-99pika1) lunar; urgency=medium * Add missing fonts diff --git a/pika-hyprland-settings/etc/skel/.config/ags/widgets/weather.js b/pika-hyprland-settings/etc/skel/.config/ags/widgets/weather.js index 0f02796..dd8583a 100644 --- a/pika-hyprland-settings/etc/skel/.config/ags/widgets/weather.js +++ b/pika-hyprland-settings/etc/skel/.config/ags/widgets/weather.js @@ -24,11 +24,14 @@ export const Weather = () => Widget.Box({ ], connections: [[900000, async box => { try { - let weather = exec(`curl https://wttr.in/${city}?format=j1`); - weather = JSON.parse(weather); - const weatherCode = weather.current_condition[0].weatherCode; - box.children[0].label = WEATHER_SYMBOL[WWO_CODE[weatherCode]]; - box.children[1].label = weather.current_condition[0].temp_C + "°C"; + // timeout here is to delay enough on boot that network has time to connect - this is a hack but for something that updates so rarely it's fine + setTimeout(() => { + let weather = exec(`curl https://wttr.in/${city}?format=j1`); + weather = JSON.parse(weather); + const weatherCode = weather.current_condition[0].weatherCode; + box.children[0].label = WEATHER_SYMBOL[WWO_CODE[weatherCode]]; + box.children[1].label = weather.current_condition[0].temp_C + "°C"; + }, 5000); } catch (err) { console.log(err); }