diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index ab3d2a3e1..1e7603379 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -116,6 +116,7 @@ let configOptions = { }, 'weather': { 'city': "", + 'preferredUnit': "C", // Either C or F }, 'workspaces': { 'shown': 10, diff --git a/.config/ags/modules/bar/normal/system.js b/.config/ags/modules/bar/normal/system.js index 468346427..7e952124d 100644 --- a/.config/ags/modules/bar/normal/system.js +++ b/.config/ags/modules/bar/normal/system.js @@ -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 * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; const { Box, Label, Button, Overlay, Revealer, Scrollable, Stack, EventBox } = Widget; @@ -161,11 +161,11 @@ const BatteryModule = () => Stack({ .catch(print); const weatherCode = weather.current_condition[0].weatherCode; const weatherDesc = weather.current_condition[0].weatherDesc[0].value; - const temperature = weather.current_condition[0].temp_C; - const feelsLike = weather.current_condition[0].FeelsLikeC; + const temperature = weather.current_condition[0][`temp_${userOptions.weather.preferredUnit}`]; + const feelsLike = weather.current_condition[0][`FeelsLike${userOptions.weather.preferredUnit}`]; const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]]; 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; }).catch((err) => { try { // Read from cache @@ -174,11 +174,11 @@ const BatteryModule = () => Stack({ ); const weatherCode = weather.current_condition[0].weatherCode; const weatherDesc = weather.current_condition[0].weatherDesc[0].value; - const temperature = weather.current_condition[0].temp_C; - const feelsLike = weather.current_condition[0].FeelsLikeC; + const temperature = weather.current_condition[0][`temp_${userOptions.weather.preferredUnit}`]; + const feelsLike = weather.current_condition[0][`FeelsLike${userOptions.weather.preferredUnit}`]; const weatherSymbol = WEATHER_SYMBOL[WWO_CODE[weatherCode]]; 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; } catch (err) { print(err);