diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-15 15:43:50 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-15 15:43:50 +1000 |
| commit | 05e9561fd687c15baba56fc9eeca9a29b504abd2 (patch) | |
| tree | a739b82c81d38727fe69c4c541a0509a75f15a8d /services/Weather.qml | |
| parent | colours: more fixes for cli rewrite (diff) | |
| download | caelestia-shell-05e9561fd687c15baba56fc9eeca9a29b504abd2.tar.gz caelestia-shell-05e9561fd687c15baba56fc9eeca9a29b504abd2.tar.bz2 caelestia-shell-05e9561fd687c15baba56fc9eeca9a29b504abd2.zip | |
internal: use stdiocollector
Removes dependency on jq
Also fix beatdetector
Diffstat (limited to 'services/Weather.qml')
| -rw-r--r-- | services/Weather.qml | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/services/Weather.qml b/services/Weather.qml index 13503f9..4f53d0b 100644 --- a/services/Weather.qml +++ b/services/Weather.qml @@ -7,6 +7,7 @@ import Quickshell.Io Singleton { id: root + property string loc property string icon property string description property real temperature @@ -15,17 +16,28 @@ Singleton { wttrProc.running = true; } + onLocChanged: wttrProc.running = true + Process { - id: wttrProc + id: ipProc running: true - command: ["fish", "-c", `curl "https://wttr.in/$(curl ipinfo.io | jq -r '.city' | string replace -a ' ' '%20')?format=j1" | jq -c '.current_condition[0] | {code: .weatherCode, desc: .weatherDesc[0].value, temp: .temp_C}'`] - stdout: SplitParser { - onRead: data => { - const json = JSON.parse(data); - root.icon = Icons.getWeatherIcon(json.code); - root.description = json.desc; - root.temperature = parseFloat(json.temp); + command: ["curl", "ipinfo.io"] + stdout: StdioCollector { + onStreamFinished: root.loc = JSON.parse(text).loc + } + } + + Process { + id: wttrProc + + command: ["curl", `https://wttr.in/${root.loc}?format=j1`] + stdout: StdioCollector { + onStreamFinished: { + const json = JSON.parse(text).current_condition[0]; + root.icon = Icons.getWeatherIcon(json.weatherCode); + root.description = json.weatherDesc[0].value; + root.temperature = parseFloat(json.temp_C); } } } |