From 05e9561fd687c15baba56fc9eeca9a29b504abd2 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 15 Jun 2025 15:43:50 +1000 Subject: internal: use stdiocollector Removes dependency on jq Also fix beatdetector --- services/Weather.qml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'services/Weather.qml') 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); } } } -- cgit v1.2.3-freya