init: working version

This commit is contained in:
Kiana Sheibani 2025-10-07 19:43:46 -04:00
commit 7d8d7dacae
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
109 changed files with 15066 additions and 0 deletions

42
services/Weather.qml Normal file
View file

@ -0,0 +1,42 @@
pragma Singleton
import qs.config
import qs.util
import Quickshell
import QtQuick
Singleton {
id: root
property string city
property var cc
property var forecast
readonly property bool available: !!cc
readonly property string icon: available ? Icons.getWeatherIcon(cc.weatherCode) : "cloud_alert"
readonly property color iconColor: available ? Icons.weatherIconColors[icon] : Config.colors.inactive
readonly property string description: cc?.weatherDesc[0].value ?? qsTr("No weather")
readonly property string temp: Config.services.useFahrenheit ? `${cc?.temp_F ?? 0}°F` : `${cc?.temp_C ?? 0}°C`
readonly property string feelsLike: Config.services.useFahrenheit ? `${cc?.FeelsLikeF ?? 0}°F` : `${cc?.FeelsLikeC ?? 0}°C`
readonly property real humidity: (cc?.humidity ?? 0) / 100
readonly property string humidityIcon: available ? Icons.getHumidityIcon(humidity) : "humidity_low"
function reload(): void {
if (Config.services.weatherLocation)
city = Config.services.weatherLocation;
else if (!city || timer.elapsed() > 900)
Requests.get("https://ipinfo.io/json", text => {
city = JSON.parse(text).city ?? "";
timer.restart();
});
}
onCityChanged: Requests.get(`https://wttr.in/${city}?format=j1`, text => {
const json = JSON.parse(text);
cc = json.current_condition[0];
forecast = json.weather;
})
ElapsedTimer {
id: timer
}
}