From b053130570c40c19c124d409d7843ad825312525 Mon Sep 17 00:00:00 2001 From: "William (Liam) Snow IV" Date: Thu, 3 Jul 2025 00:08:25 -0400 Subject: feat: fahrenheit option for weather (#189) * Added Fahrenheit to Weather Service * some fixes Allow for hot reloading config opt Add opt to example config --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> --- README.md | 3 ++- config/DashboardConfig.qml | 1 + modules/dashboard/dash/Weather.qml | 2 +- modules/lock/WeatherInfo.qml | 2 +- services/Weather.qml | 6 ++++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 467c1d3..03e0319 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,8 @@ All configuration options are in `~/.config/caelestia/shell.json`. "dashboard": { "mediaUpdateInterval": 500, "visualiserBars": 45, - "weatherLocation": "10,10" + "weatherLocation": "10,10", + "useFahrenheit": false, }, "launcher": { "actionPrefix": ">", diff --git a/config/DashboardConfig.qml b/config/DashboardConfig.qml index 02f838e..201b8d3 100644 --- a/config/DashboardConfig.qml +++ b/config/DashboardConfig.qml @@ -4,6 +4,7 @@ JsonObject { property int mediaUpdateInterval: 500 property int visualiserBars: 45 property string weatherLocation: "" // A lat,long pair, e.g. "37.8267,-122.4233" + property bool useFahrenheit: false property JsonObject sizes: JsonObject { readonly property int tabIndicatorHeight: 3 diff --git a/modules/dashboard/dash/Weather.qml b/modules/dashboard/dash/Weather.qml index cc19385..f7d0f9b 100644 --- a/modules/dashboard/dash/Weather.qml +++ b/modules/dashboard/dash/Weather.qml @@ -38,7 +38,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter animate: true - text: `${Weather.temperature}°C` + text: Config.dashboard.useFahrenheit ? Weather.tempF : Weather.tempC color: Colours.palette.m3primary font.pointSize: Appearance.font.size.extraLarge font.weight: 500 diff --git a/modules/lock/WeatherInfo.qml b/modules/lock/WeatherInfo.qml index 1b840e6..7ed64dc 100644 --- a/modules/lock/WeatherInfo.qml +++ b/modules/lock/WeatherInfo.qml @@ -40,7 +40,7 @@ RowLayout { Layout.fillWidth: true animate: true - text: `${Weather.temperature}°C` + text: Config.dashboard.useFahrenheit ? Weather.tempF : Weather.tempC color: Colours.palette.m3primary horizontalAlignment: Text.AlignHCenter font.pointSize: Appearance.font.size.extraLarge diff --git a/services/Weather.qml b/services/Weather.qml index ad80e48..ae0e0b6 100644 --- a/services/Weather.qml +++ b/services/Weather.qml @@ -11,7 +11,8 @@ Singleton { property string loc property string icon property string description - property real temperature + property string tempC: "0°C" + property string tempF: "0°F" function reload(): void { if (Config.dashboard.weatherLocation) @@ -27,7 +28,8 @@ Singleton { const json = JSON.parse(text).current_condition[0]; icon = Icons.getWeatherIcon(json.weatherCode); description = json.weatherDesc[0].value; - temperature = parseFloat(json.temp_C); + tempC = `${parseFloat(json.temp_C)}°C`; + tempF = `${parseFloat(json.temp_F)}°F`; }) Component.onCompleted: reload() -- cgit v1.2.3-freya