github.com/wtfutil/wtf@v0.43.0/modules/resourceusage/settings.go (about) 1 package resourceusage 2 3 import ( 4 "github.com/olebedev/config" 5 "github.com/wtfutil/wtf/cfg" 6 ) 7 8 const ( 9 defaultFocusable = false 10 defaultRefreshInterval = "1s" 11 defaultTitle = "ResourceUsage" 12 ) 13 14 type Settings struct { 15 *cfg.Common 16 17 cpuCombined bool 18 showCPU bool 19 showMem bool 20 showSwp bool 21 } 22 23 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 24 settings := Settings{ 25 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 26 27 cpuCombined: ymlConfig.UBool("cpuCombined", false), 28 showCPU: ymlConfig.UBool("showCPU", true), 29 showMem: ymlConfig.UBool("showMem", true), 30 showSwp: ymlConfig.UBool("showSwp", true), 31 } 32 settings.Common.RefreshInterval = cfg.ParseTimeString(ymlConfig, "refreshInterval", defaultRefreshInterval) 33 34 return &settings 35 }