diff --git a/bar/clicks.go b/bar/clicks.go index 896a76b72d5d516d8cdbcddbeed41b14bc9469c8..bd510312b94e9edf0716dbd907ad7e586998ded7 100644 --- a/bar/clicks.go +++ b/bar/clicks.go @@ -12,7 +12,22 @@ import ( "gopkg.in/yaml.v2" ) -//{"button":1,"modifiers":[],"x":1952,"y":1144,"relative_x":62,"relative_y":14,"width":112,"height":22} +/* +An example click: + + { + "name": "thing", + "button": 1, + "modifiers": [], + "x": 1952, + "y": 1144, + "relative_x": 62, + "relative_y": 14, + "width": 112, + "height": 22 + } +*/ + func handleCommands(clicks chan modules.Click) { logger, _ := os.Create("/tmp/i3going-on.log") diff --git a/config/config.go b/config/config.go index bb06e38e3e3c02b993d5a7173bd6abcfc638b41d..770d5963bef10224a52b147d42e936a2d388ba8f 100644 --- a/config/config.go +++ b/config/config.go @@ -36,6 +36,10 @@ func ReadConfig(configFile string) *Config { modules.NewErrorModule("decode", err), }, } + } else { + for _, module := range cfg.Modules { + module.SetDefaults() + } } return cfg diff --git a/modules/battery.go b/modules/battery.go index 4ea57cdec879a97ae7d3aea4f10a37ff009fe99e..c3d491a8a33197baa4902a8ff1b458c929871be0 100644 --- a/modules/battery.go +++ b/modules/battery.go @@ -100,10 +100,6 @@ func (b *BatteryMod) Render() string { } left := "(?)" if len(b.battStats) >= 1 { - b.battStats = append(b.battStats, battTS{ - charge: batt.Current, - point: now, - }) delta := now.Sub(b.battStats[0].point) if delta >= (60 * time.Second) { discharge := math.Abs(batt.Current - b.battStats[0].charge) @@ -112,6 +108,10 @@ func (b *BatteryMod) Render() string { b.battStats = b.battStats[1:] } } + b.battStats = append(b.battStats, battTS{ + charge: batt.Current, + point: now, + }) states := [...]string{ battery.Unknown: b.StatusUnk, @@ -122,7 +122,7 @@ func (b *BatteryMod) Render() string { } color := b.ColorOK - percent := batt.Current / batt.Full + percent := 100 * (batt.Current / batt.Full) if percent < 20 { if percent < 10 { color = b.Color10 diff --git a/modules/modules.go b/modules/modules.go index 2322c637fc3df24944855caa0b0386ea77b310a2..249210e92f89b51b568d40e44c6e6c21eb0b8b1f 100644 --- a/modules/modules.go +++ b/modules/modules.go @@ -60,3 +60,7 @@ func (m *Module) UnmarshalYAML(node *yaml.Node) error { func (m *Module) Render() string { return m.Params.Render() } + +func (m *Module) SetDefaults() { + m.Params.SetDefaults() +}