From 0b63a56e401dc8c852f56a1d5e003bb0c1a97078 Mon Sep 17 00:00:00 2001 From: Jon Hadfield Date: Mon, 22 Jun 2020 18:47:28 +0100 Subject: [PATCH] enable user to disable emoji for weather module. --- modules/weatherservices/weather/display.go | 6 +++++- modules/weatherservices/weather/settings.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/weatherservices/weather/display.go b/modules/weatherservices/weather/display.go index 1ee2819e..3f118efd 100644 --- a/modules/weatherservices/weather/display.go +++ b/modules/weatherservices/weather/display.go @@ -81,5 +81,9 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string { } func (widget *Widget) buildTitle(cityData *owm.CurrentWeatherData) string { - return fmt.Sprintf("%s %s", widget.emojiFor(cityData), cityData.Name) + if widget.settings.useEmoji { + return fmt.Sprintf("%s %s", widget.emojiFor(cityData), cityData.Name) + } + + return fmt.Sprintf("%s", cityData.Name) } diff --git a/modules/weatherservices/weather/settings.go b/modules/weatherservices/weather/settings.go index 6176bba3..816b0d45 100644 --- a/modules/weatherservices/weather/settings.go +++ b/modules/weatherservices/weather/settings.go @@ -24,6 +24,7 @@ type Settings struct { cityIDs []interface{} language string tempUnit string + useEmoji bool } func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { @@ -34,6 +35,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co cityIDs: ymlConfig.UList("cityids"), language: ymlConfig.UString("language", "EN"), tempUnit: ymlConfig.UString("tempUnit", "C"), + useEmoji: ymlConfig.UBool("useEmoji", true), } settings.colors.current = ymlConfig.UString("colors.current", "green")