diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-18 09:33:08 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-18 09:33:08 +0200 |
| commit | f1951f2ee1e83d802030c257d4a1df099ec08976 (patch) | |
| tree | bce1d38cc5b78e4cb5d80d6e0d316267bb15cb9f /internal/config | |
| parent | d845cf3208c3bbdb7e3dd3041d1ae491b88d4d21 (diff) | |
feat: add fixed load scale (--loadmax), load peak reset (r key), update README
- config: add LoadMax float64 field; loadmax key in ~/.loadbarsrc; written by 'w'
- main: add --loadmax flag (overrides rc file when > 0)
- display: newRunState initialises loadPeak from LoadMax when fixed
- display: updateLoadPeak accepts loadMax param; short-circuits to fixed value when set
- display: add 'r' hotkey to reset auto-scale peak to floor (2.0); no-op when fixed
- tooltip: loadTooltipLines shows 'Max:' label when scale is fixed, 'Peak:' for auto
- README: document 4/l load toggle, r reset, --showload, --loadmax, load average bars section; fix --cpumode entry
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 99e9c6d..3625341 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -30,6 +30,7 @@ type Config struct { ShowMem bool ShowNet bool ShowLoad bool + LoadMax float64 // 0 = auto-scale; >0 = fixed full-height reference value ShowSeparators bool MaxBarsPerRow int SSHOpts string @@ -110,7 +111,7 @@ func (c *Config) parseReader(f *os.File) error { "title": true, "barwidth": true, "cpuaverage": true, "extended": true, "hasagent": true, "height": true, "maxwidth": true, "netaverage": true, "netlink": true, "cpumode": true, "showcores": true, "showmem": true, - "showavgline": true, "showioavgline": true, "shownet": true, "showload": true, "showseparators": true, + "showavgline": true, "showioavgline": true, "shownet": true, "showload": true, "loadmax": true, "showseparators": true, "maxbarsperrow": true, "sshopts": true, "cluster": true, } scanner := bufio.NewScanner(f) @@ -188,6 +189,11 @@ func (c *Config) set(key, val string) { c.ShowNet = parseBool(val) case "showload": c.ShowLoad = parseBool(val) + case "loadmax": + // Accept any non-negative float; 0 means auto-scale. + if f, err := strconv.ParseFloat(val, 64); err == nil && f >= 0 { + c.LoadMax = f + } case "showseparators": c.ShowSeparators = parseBool(val) case "maxbarsperrow": @@ -205,6 +211,8 @@ func (c *Config) writeTo(f *os.File) error { w := bufio.NewWriter(f) writeInt := func(key string, v int) { fmt.Fprintf(w, "%s=%d\n", key, v) } writeStr := func(key, v string) { fmt.Fprintf(w, "%s=%s\n", key, v) } + // writeFloat uses %g to strip trailing zeros (e.g. 8 → "8", 8.5 → "8.5"). + writeFloat := func(key string, v float64) { fmt.Fprintf(w, "%s=%g\n", key, v) } writeBool := func(key string, v bool) { val := "0" if v { @@ -226,6 +234,7 @@ func (c *Config) writeTo(f *os.File) error { writeBool("showmem", c.ShowMem) writeBool("shownet", c.ShowNet) writeBool("showload", c.ShowLoad) + writeFloat("loadmax", c.LoadMax) writeBool("showseparators", c.ShowSeparators) writeInt("maxbarsperrow", c.MaxBarsPerRow) writeStr("sshopts", c.SSHOpts) |
