From b6a34cbc47fcef2f0b8b828314290f4e1270dae0 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 28 May 2025 22:03:05 +0800 Subject: internal: move weather into service Also fix not escaping city properly --- services/Weather.qml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 services/Weather.qml (limited to 'services') diff --git a/services/Weather.qml b/services/Weather.qml new file mode 100644 index 0000000..13503f9 --- /dev/null +++ b/services/Weather.qml @@ -0,0 +1,32 @@ +pragma Singleton + +import "root:/utils" +import Quickshell +import Quickshell.Io + +Singleton { + id: root + + property string icon + property string description + property real temperature + + function reload(): void { + wttrProc.running = true; + } + + Process { + id: wttrProc + + 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); + } + } + } +} -- cgit v1.2.3-freya