Skip to content

Commit 42e2050

Browse files
committed
Add GPU, network, disk, battery & UI enhancements
Introduce expanded metrics, UI, and configuration support: add collectors for network, disk, battery, temperature and delta computation (with tests), and pluggable GPU backends (Apple/NVIDIA/AMD). Enhance the Bubble Tea model and UI with sparklines, themes, process detail overlay, mouse support, kill/export actions, improved selection handling, and responsive two-column layout. Add CLI flags and JSON config file loading (~/.config/hideTop/config.json) and propagate options to the collector (SkipGPU/SkipTemp). Also add a CI workflow (GitHub Actions) and various UI/metrics files to support the new features.
1 parent 596a9b1 commit 42e2050

33 files changed

+2825
-177
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
go-version: ["1.23", "1.24"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ matrix.go-version }}
26+
27+
- name: Build
28+
run: go build ./...
29+
30+
- name: Test
31+
run: go test -race -count=1 ./...
32+
33+
- name: Vet
34+
run: go vet ./...
35+
36+
lint:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: "1.24"
45+
46+
- name: golangci-lint
47+
uses: golangci/golangci-lint-action@v6
48+
with:
49+
version: latest

README.md

Lines changed: 100 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,40 @@ Built with [Bubble Tea](https://github.com/charmbracelet/bubbletea) and [Lip Glo
66

77
## Features
88

9-
- **CPU** — total + per-core utilisation bars with core count, colour-coded by load
10-
- **GPU** *(Apple Silicon)* — total + per-engine (Tiler / Renderer) utilisation, core count, frequency, thermal pressure indicator, and heuristic energy impact score. Auto-detected at runtime; hidden on unsupported hardware
11-
- **Memory** — used / total / available GiB with bar; conditional swap bar when swap is active
9+
- **CPU** — total + per-core utilisation bars with core count, colour-coded by load, sparkline history
10+
- **GPU** — total + per-engine utilisation, core count, frequency, thermal pressure indicator, and heuristic energy impact score. Auto-detected at runtime; hidden on unsupported hardware. Supports **Apple Silicon** (ioreg), **NVIDIA** (nvidia-smi), and **AMD** (sysfs)
11+
- **Memory** — used / total / available GiB with bar; conditional swap bar when swap is active; sparkline history
1212
- **Load Average** — 1 / 5 / 15 minute
13-
- **Processes** — sortable by CPU, memory, or PID with visual sort indicators (▲/▼); PID-based row selection (↑↓ / j/k); incremental search (`/`); auto-scrolling viewport
14-
- **Refresh control**`+`/`-` to adjust interval with visual flash feedback
15-
- **Configurable**`--interval` flag (default 1s, minimum 100ms)
13+
- **Temperature** — up to 6 sensors in a 2-column grid, auto-detects CPU/GPU temps, colour-coded by threshold (green < 60°C, yellow 60–80°C, red > 80°C). Disable with `--no-temp`
14+
- **Network** — total in/out throughput (bytes/s), per-interface breakdown (up to 4 active interfaces)
15+
- **Disk** — total read/write throughput (bytes/s), root filesystem usage
16+
- **Battery** — percentage and charging status in the header bar (macOS via `pmset`, Linux via sysfs)
17+
- **Processes** — sortable by CPU, memory, or PID with visual sort indicators (▲/▼); columns for PID, state (R/S/Z/T), user, name, threads, CPU%, MEM%; PID-based row selection; incremental search by name, PID, or username; tree view; system process filter; process detail panel (Enter); kill / force kill with confirmation
18+
- **Themes** — 5 built-in themes: `dark` (default), `light`, `dracula`, `nord`, `monokai`
19+
- **Responsive layout** — two-column layout at ≥ 110 cols, single-column stacked on narrower terminals
20+
- **Mouse support** — scroll wheel to navigate process list, click to select
21+
- **Export** — snapshot to JSON with `e`
22+
- **Configurable** — CLI flags and `~/.config/hideTop/config.json`
1623

1724
## Keyboard shortcuts
1825

1926
| Key | Action |
2027
|-----|--------|
2128
| `` `` / `j` `k` | Move process selection |
22-
| `/` | Start incremental search, `Esc` to cancel |
29+
| `/` | Start incremental search (name, PID, or user), `Esc` to cancel |
30+
| `Enter` | Open process detail panel |
2331
| `c` | Sort by CPU% (descending) |
2432
| `m` | Sort by MEM% (descending) |
2533
| `p` | Sort by PID (ascending) |
26-
| `+` `-` | Increase / decrease refresh interval |
34+
| `t` | Toggle tree view |
35+
| `s` | Toggle system process filter |
36+
| `x` | Kill selected process (SIGTERM, asks for confirmation) |
37+
| `K` | Force kill selected process (SIGKILL, asks for confirmation) |
38+
| `+` / `=` | Increase refresh interval (+250ms) |
39+
| `-` / `_` | Decrease refresh interval (-250ms) |
40+
| `e` | Export snapshot to JSON |
41+
| `?` | Toggle help overlay |
42+
| `Esc` | Close help / detail / cancel search |
2743
| `q` / `Ctrl+C` | Quit |
2844

2945
## Installation
@@ -39,40 +55,87 @@ brew install hidetop
3955
go build -o hideTop ./src/
4056
./hideTop # default 1s refresh
4157
./hideTop --interval 500ms # faster refresh
58+
./hideTop --theme dracula # use dracula theme
59+
./hideTop --no-gpu --no-temp # disable GPU and temperature panels
4260
./hideTop --version # print version and exit
4361
# local build with git tag in --version:
4462
go build -ldflags "-X main.Version=$(git describe --tags --always --dirty)" -o hideTop ./src/
4563
```
4664

65+
## Configuration
66+
67+
CLI flags take precedence over the config file.
68+
69+
| Flag | Default | Description |
70+
|------|---------|-------------|
71+
| `--interval` | `1s` | Metrics refresh interval (min 100ms) |
72+
| `--theme` | `dark` | Colour theme (`dark`, `light`, `dracula`, `nord`, `monokai`) |
73+
| `--no-gpu` | `false` | Disable GPU metrics |
74+
| `--no-temp` | `false` | Disable temperature metrics |
75+
| `--debug` | `false` | Enable debug logging to stderr |
76+
| `--version` / `-v` || Print version and exit |
77+
78+
### Config file
79+
80+
`~/.config/hideTop/config.json`
81+
82+
```json
83+
{
84+
"interval": "1s",
85+
"theme": "dracula",
86+
"no_gpu": false,
87+
"no_temp": false,
88+
"debug": false,
89+
"filter_users": ["root", "_windowserver", "nobody"]
90+
}
91+
```
92+
93+
The `filter_users` array controls which usernames are hidden when the system process filter (`s`) is active. Defaults to `["root", "_windowserver", "nobody"]` if not set.
94+
4795
## Project structure
4896

4997
```
5098
hideTop/
51-
├── src/ # Entry point
52-
│ └── main.go
99+
├── src/
100+
│ └── main.go # Entry point
53101
├── internal/
54-
│ ├── app/ # Bubble Tea model, update loop, view
55-
│ │ └── model.go
56-
│ ├── config/ # CLI flags & configuration
57-
│ │ └── config.go
58-
│ ├── metrics/ # System metrics collectors
59-
│ │ ├── types.go # Shared data types (Snapshot, CPUStats, …)
60-
│ │ ├── collector.go # Concurrent aggregation of all metrics
102+
│ ├── app/
103+
│ │ └── model.go # Bubble Tea model, update loop, view
104+
│ ├── config/
105+
│ │ └── config.go # CLI flags & config file
106+
│ ├── metrics/
107+
│ │ ├── types.go # Shared data types (Snapshot, ProcessInfo, …)
108+
│ │ ├── collector.go # Concurrent aggregation of all metrics
61109
│ │ ├── cpu.go
62110
│ │ ├── memory.go
63111
│ │ ├── processes.go
64-
│ │ └── gpu/ # Apple Silicon GPU metrics (ioreg-based)
65-
│ │ ├── gpu.go # Main collector, types & capability detection
66-
│ │ ├── engines.go # Per-engine utilisation parser (Tiler, Renderer)
67-
│ │ ├── thermal.go # Thermal pressure via pmset
68-
│ │ └── energy.go # Heuristic energy impact calculator
69-
│ └── ui/ # Pure rendering functions (Lip Gloss)
70-
│ ├── styles.go # Colour palette & shared styles
112+
│ │ ├── temperature.go
113+
│ │ ├── network.go
114+
│ │ ├── disk.go
115+
│ │ ├── battery.go
116+
│ │ └── gpu/ # GPU metrics (pluggable backends)
117+
│ │ ├── backend.go # Backend interface
118+
│ │ ├── gpu.go # Runtime detection & dispatch
119+
│ │ ├── apple.go # Apple Silicon (ioreg)
120+
│ │ ├── nvidia.go # NVIDIA (nvidia-smi)
121+
│ │ ├── amd.go # AMD (sysfs)
122+
│ │ ├── engines.go # Per-engine utilisation parser
123+
│ │ ├── thermal.go # Thermal pressure (macOS pmset)
124+
│ │ └── energy.go # Heuristic energy impact
125+
│ └── ui/
126+
│ ├── styles.go # Colour palette & shared styles
127+
│ ├── themes.go # Theme definitions
128+
│ ├── sparkline.go # Sparkline renderer
71129
│ ├── cpu.go
72130
│ ├── gpu.go
73131
│ ├── memory.go
74-
│ ├── processes.go
75-
│ └── help.go
132+
│ ├── temperature.go
133+
│ ├── network.go
134+
│ ├── disk.go
135+
│ ├── battery.go
136+
│ ├── processes.go # Process table
137+
│ ├── process_detail.go # Process detail overlay
138+
│ └── help.go # Help bar & overlay
76139
├── go.mod
77140
├── go.sum
78141
└── README.md
@@ -82,23 +145,25 @@ hideTop/
82145

83146
| Layer | Package | Responsibility |
84147
|-------|---------|---------------|
85-
| **Entry** | `src` | Parse config, wire up Bubble Tea |
148+
| **Entry** | `src` | Parse config, wire up Bubble Tea, enable mouse & alt screen |
86149
| **App** | `internal/app` | Bubble Tea Model / Update / View, owns the event loop |
87-
| **Metrics** | `internal/metrics` | CPU, memory, load, processes via gopsutil; concurrent collection |
88-
| **GPU** | `internal/metrics/gpu` | Apple Silicon GPU via `ioreg` + `pmset` (no sudo required) |
89-
| **UI** | `internal/ui` | Pure functions: data in → styled string out |
90-
| **Config** | `internal/config` | CLI flags, future file-based config |
150+
| **Metrics** | `internal/metrics` | CPU, memory, load, processes, temperature, network, disk, battery via gopsutil; concurrent collection with graceful degradation |
151+
| **GPU** | `internal/metrics/gpu` | Pluggable backends: Apple Silicon (`ioreg`), NVIDIA (`nvidia-smi`), AMD (sysfs). No sudo required |
152+
| **UI** | `internal/ui` | Pure functions: data in → styled string out. Themes, sparklines, process table, detail overlay |
153+
| **Config** | `internal/config` | CLI flags + `~/.config/hideTop/config.json` |
91154

92155
Key design decisions:
93156
- **No global mutable state** — all state lives in the Bubble Tea `Model`.
94157
- **Async collection** — metrics are gathered in a `tea.Cmd` goroutine, so the UI never blocks.
95-
- **Concurrent collectors** — CPU, memory, load, and processes run in parallel via `sync.WaitGroup`; GPU runs sequentially after (needs CPU total for energy calculation).
158+
- **Concurrent collectors** — CPU, memory, load, network, disk, battery, temperature, and processes run in parallel via `sync.WaitGroup`; GPU runs sequentially after (needs CPU total for energy calculation).
159+
- **Graceful degradation** — if a collector fails or times out, the previous snapshot is used and a `stale` indicator appears in the header.
96160
- **Pure rendering** — UI functions take data + width and return strings. No side effects, easy to test.
97161
- **Runtime detection** — GPU support is detected via `runtime.GOOS` + `runtime.GOARCH` and cached with `sync.Once`. No build tags needed; the binary works on any platform.
98-
- **No sudo** — all data sources (`ioreg`, `pmset`, gopsutil) work without elevated privileges.
99-
- **PID-based selection** — process selection tracks by PID, surviving refresh cycles, re-sorts, and search filters.
162+
- **No sudo** — all data sources (`ioreg`, `pmset`, `nvidia-smi`, sysfs, gopsutil) work without elevated privileges.
163+
- **PID-based selection** — process selection tracks by PID, surviving refresh cycles, re-sorts, and search filters. Falls back to same visual position when a process disappears.
164+
- **Responsive layout** — panels pair in two columns when the terminal is ≥ 110 columns wide, with matched heights.
100165

101166
## Requirements
102167

103168
- Go 1.25+
104-
- macOS or Linux (GPU panel requires Apple Silicon)
169+
- macOS or Linux (GPU panel: Apple Silicon, NVIDIA with nvidia-smi, or AMD with sysfs)

0 commit comments

Comments
 (0)