1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-27 13:42:21 -07:00

WTF-482 Sanity-check position configuration data for modules

If a module is missing any of the positional data it now informs the
user and exits gracefully with an error.
This commit is contained in:
Chris Cummer
2019-07-04 21:17:39 -07:00
parent d76f6807cc
commit 08c7e768c0
3 changed files with 82 additions and 13 deletions

View File

@@ -30,12 +30,12 @@ type Module struct {
Type string
}
type Position struct {
Height int
Left int
Top int
Width int
}
// type Position struct {
// Height int
// Left int
// Top int
// Width int
// }
type Sigils struct {
Checkbox struct {
@@ -64,7 +64,7 @@ type Common struct {
func NewCommonSettingsFromModule(name, defaultTitle string, moduleConfig *config.Config, globalSettings *config.Config) *Common {
colorsConfig, _ := globalSettings.Get("wtf.colors")
positionPath := "position"
// positionPath := "position"
sigilsPath := "wtf.sigils"
common := Common{
@@ -86,12 +86,7 @@ func NewCommonSettingsFromModule(name, defaultTitle string, moduleConfig *config
Type: moduleConfig.UString("type", name),
},
Position: Position{
Height: moduleConfig.UInt(positionPath + ".height"),
Left: moduleConfig.UInt(positionPath + ".left"),
Top: moduleConfig.UInt(positionPath + ".top"),
Width: moduleConfig.UInt(positionPath + ".width"),
},
Position: NewPositionFromYAML(name, moduleConfig),
Enabled: moduleConfig.UBool("enabled", false),
RefreshInterval: moduleConfig.UInt("refreshInterval", 300),