diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-24 20:42:43 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-24 20:42:43 +1000 |
| commit | 748bfa9358b52c6d1d92899112fc522896548206 (patch) | |
| tree | b6fc17549ae9c5abee476f49790367ad7828744c | |
| parent | Revert "hyprland: fix active client on empty ws" (diff) | |
| download | caelestia-shell-748bfa9358b52c6d1d92899112fc522896548206.tar.gz caelestia-shell-748bfa9358b52c6d1d92899112fc522896548206.tar.bz2 caelestia-shell-748bfa9358b52c6d1d92899112fc522896548206.zip | |
weather: use city instead of lat/long
Also lazy load
| -rw-r--r-- | services/Weather.qml | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/services/Weather.qml b/services/Weather.qml index 02458c2..f3147a8 100644 --- a/services/Weather.qml +++ b/services/Weather.qml @@ -8,7 +8,7 @@ import QtQuick Singleton { id: root - property string loc + property string city property var cc property var forecast readonly property string icon: cc ? Icons.getWeatherIcon(cc.weatherCode) : "cloud_alert" @@ -19,22 +19,20 @@ Singleton { function reload(): void { if (Config.services.weatherLocation) - loc = Config.services.weatherLocation; - else if (!loc || timer.elapsed() > 900) + city = Config.services.weatherLocation; + else if (!city || timer.elapsed() > 900) Requests.get("https://ipinfo.io/json", text => { - loc = JSON.parse(text).loc ?? ""; + city = JSON.parse(text).city ?? ""; timer.restart(); }); } - onLocChanged: Requests.get(`https://wttr.in/${loc}?format=j1`, text => { + onCityChanged: Requests.get(`https://wttr.in/${city}?format=j1`, text => { const json = JSON.parse(text); cc = json.current_condition[0]; forecast = json.weather; }) - Component.onCompleted: reload() - ElapsedTimer { id: timer } |