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/display/tooltip.go | |
| 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/display/tooltip.go')
| -rw-r--r-- | internal/display/tooltip.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/display/tooltip.go b/internal/display/tooltip.go index e5cf951..77ee365 100644 --- a/internal/display/tooltip.go +++ b/internal/display/tooltip.go @@ -37,7 +37,7 @@ func tooltipLines(bar *barDescriptor, snap map[string]*stats.HostStats, cfg *con case barNet: return netTooltipLines(bar, cfg, state) case barLoad: - return loadTooltipLines(bar, h, state) + return loadTooltipLines(bar, h, cfg, state) } return nil } @@ -101,8 +101,10 @@ func netTooltipLines(bar *barDescriptor, cfg *config.Config, state *runState) [] } // loadTooltipLines returns tooltip text for a load-average bar showing -// the smoothed 1/5/15-min averages and the current global peak scale. -func loadTooltipLines(bar *barDescriptor, h *stats.HostStats, state *runState) []string { +// the 1/5/15-min averages and the current scale reference. +// When cfg.LoadMax > 0 the scale is fixed and the label reads "Max:"; +// otherwise it tracks the auto-scale peak and reads "Peak:". +func loadTooltipLines(bar *barDescriptor, h *stats.HostStats, cfg *config.Config, state *runState) []string { lines := []string{fmt.Sprintf("%s [load]", bar.host)} l1, err1 := strconv.ParseFloat(strings.TrimSpace(h.LoadAvg1), 64) l5, err5 := strconv.ParseFloat(strings.TrimSpace(h.LoadAvg5), 64) @@ -111,11 +113,15 @@ func loadTooltipLines(bar *barDescriptor, h *stats.HostStats, state *runState) [ lines = append(lines, "No data yet") return lines } + scaleLabel := "Peak: " + if cfg.LoadMax > 0 { + scaleLabel = "Max: " + } lines = append(lines, fmt.Sprintf("1min: %.2f", l1), fmt.Sprintf("5min: %.2f", l5), fmt.Sprintf("15min: %.2f", l15), - fmt.Sprintf("Peak: %.2f", state.loadPeak), + fmt.Sprintf(scaleLabel+"%.2f", state.loadPeak), ) return lines } |
