mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add 'withDate' option to digitalclock module (#797)
When `withDate` is `true`, it displays date information below the clock. When `withDate` is `false`, it does not display date information. Defaults to `true`. Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
091b2b975f
commit
a7facc85fa
@ -8,15 +8,20 @@ func mergeLines(outString []string) string {
|
|||||||
|
|
||||||
func renderWidget(widgetSettings Settings) string {
|
func renderWidget(widgetSettings Settings) string {
|
||||||
outputStrings := []string{}
|
outputStrings := []string{}
|
||||||
|
|
||||||
clockString, needBorder := renderClock(widgetSettings)
|
clockString, needBorder := renderClock(widgetSettings)
|
||||||
if needBorder {
|
if needBorder {
|
||||||
outputStrings = append(outputStrings, mergeLines([]string{"", clockString, ""}))
|
outputStrings = append(outputStrings, mergeLines([]string{"", clockString, ""}))
|
||||||
} else {
|
} else {
|
||||||
outputStrings = append(outputStrings, clockString)
|
outputStrings = append(outputStrings, clockString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if widgetSettings.withDate {
|
||||||
outputStrings = append(outputStrings, getDate())
|
outputStrings = append(outputStrings, getDate())
|
||||||
outputStrings = append(outputStrings, getUTC())
|
outputStrings = append(outputStrings, getUTC())
|
||||||
outputStrings = append(outputStrings, getEpoch())
|
outputStrings = append(outputStrings, getEpoch())
|
||||||
|
}
|
||||||
|
|
||||||
return mergeLines(outputStrings)
|
return mergeLines(outputStrings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,20 +14,21 @@ const (
|
|||||||
type Settings struct {
|
type Settings struct {
|
||||||
common *cfg.Common
|
common *cfg.Common
|
||||||
|
|
||||||
hourFormat string `help:"The format of the clock." values:"12 or 24"`
|
|
||||||
color string `help:"The color of the clock."`
|
color string `help:"The color of the clock."`
|
||||||
font string `help:"The font of the clock." values:"bigfont or digitalfont"`
|
font string `help:"The font of the clock." values:"bigfont or digitalfont"`
|
||||||
|
hourFormat string `help:"The format of the clock." values:"12 or 24"`
|
||||||
|
withDate bool `help:"Whether or not to display date information"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSettingsFromYAML creates a new settings instance from a YAML config block
|
// NewSettingsFromYAML creates a new settings instance from a YAML config block
|
||||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||||
|
|
||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||||
|
|
||||||
color: ymlConfig.UString("color"),
|
color: ymlConfig.UString("color"),
|
||||||
font: ymlConfig.UString("font"),
|
font: ymlConfig.UString("font"),
|
||||||
hourFormat: ymlConfig.UString("hourFormat", "24"),
|
hourFormat: ymlConfig.UString("hourFormat", "24"),
|
||||||
|
withDate: ymlConfig.UBool("withDate", true),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &settings
|
return &settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user