forked from Shinonome/dots-hyprland
weather: config option for deg c or f (#602)
This commit is contained in:
@@ -116,6 +116,7 @@ let configOptions = {
|
|||||||
},
|
},
|
||||||
'weather': {
|
'weather': {
|
||||||
'city': "",
|
'city': "",
|
||||||
|
'preferredUnit': "C", // Either C or F
|
||||||
},
|
},
|
||||||
'workspaces': {
|
'workspaces': {
|
||||||
'shown': 10,
|
'shown': 10,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// This is for the right pills of the bar.
|
// This is for the right pills of the bar.
|
||||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
const { Box, Label, Button, Overlay, Revealer, Scrollable, Stack, EventBox } = Widget;
|
const { Box, Label, Button, Overlay, Revealer, Scrollable, Stack, EventBox } = Widget;
|
||||||
@@ -161,11 +161,11 @@ const BatteryModule = () => Stack({
|
|||||||
.catch(print);
|
.catch(print);
|
||||||
const weatherCode = weather.current_condition[0].weatherCode;
|
const weatherCode = weather.current_condition[0].weatherCode;
|
||||||
const weatherDesc = weather.current_condition[0].weatherDesc[0].value;
|
const weatherDesc = weather.current_condition[0].weatherDesc[0].value;
|
||||||
const temperature = weather.current_condition[0].temp_C;
|
const temperature = weather.current_condition[0][`temp_${userOptions.weather.preferredUnit}`];
|
||||||
const feelsLike = weather.current_condition[0].FeelsLikeC;
|
const feelsLike = weather.current_condition[0][`FeelsLike${userOptions.weather.preferredUnit}`];
|
||||||
const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]];
|
const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]];
|
||||||
self.children[0].label = weatherSymbol;
|
self.children[0].label = weatherSymbol;
|
||||||
self.children[1].label = `${temperature}℃ • Feels like ${feelsLike}℃`;
|
self.children[1].label = `${temperature}°${userOptions.weather.preferredUnit} • Feels like ${feelsLike}°${userOptions.weather.preferredUnit}`;
|
||||||
self.tooltipText = weatherDesc;
|
self.tooltipText = weatherDesc;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
try { // Read from cache
|
try { // Read from cache
|
||||||
@@ -174,11 +174,11 @@ const BatteryModule = () => Stack({
|
|||||||
);
|
);
|
||||||
const weatherCode = weather.current_condition[0].weatherCode;
|
const weatherCode = weather.current_condition[0].weatherCode;
|
||||||
const weatherDesc = weather.current_condition[0].weatherDesc[0].value;
|
const weatherDesc = weather.current_condition[0].weatherDesc[0].value;
|
||||||
const temperature = weather.current_condition[0].temp_C;
|
const temperature = weather.current_condition[0][`temp_${userOptions.weather.preferredUnit}`];
|
||||||
const feelsLike = weather.current_condition[0].FeelsLikeC;
|
const feelsLike = weather.current_condition[0][`FeelsLike${userOptions.weather.preferredUnit}`];
|
||||||
const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]];
|
const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]];
|
||||||
self.children[0].label = weatherSymbol;
|
self.children[0].label = weatherSymbol;
|
||||||
self.children[1].label = `${temperature}℃ • Feels like ${feelsLike}℃`;
|
self.children[1].label = `${temperature}°${userOptions.weather.preferredUnit} • Feels like ${feelsLike}°${userOptions.weather.preferredUnit}`;
|
||||||
self.tooltipText = weatherDesc;
|
self.tooltipText = weatherDesc;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print(err);
|
print(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user