Terminal system monitor in Gleam — htop × btop
1.9 kB
62 lines
1# monitor
2
3A terminal system monitor written in **Gleam** — sits between **htop** and **btop**.
4
5| From htop | From btop |
6|-----------|-----------|
7| Dense process table (PID, USER, PRI, NI, VIRT, RES, S, CPU%, MEM%, TIME+, Command) | Color meters & sparklines for CPU / memory / swap |
8| Sort by column, filter (`/`), kill (`k`) | Per-core CPU bars |
9| Keyboard + mouse navigation | Clean alternate-screen TUI |
10
11## Requirements
12
13- Linux (`/proc`)
14- [Gleam](https://gleam.run) + Erlang/OTP
15- A modern terminal (truecolor optional, 256-color fine)
16
17## Run
18
19```sh
20# if Erlang isn't on PATH (NixOS):
21nix develop # or: nix-shell -p gleam beamPackages.erlang
22gleam run
23```
24
25## Keys
26
27| Key | Action |
28|-----|--------|
29| `↑` / `u` · `↓` / `j` | Move selection (htop-style: `k` is kill, not up) |
30| `PgUp` / `PgDn` | Page |
31| `g` / `G` | Top / bottom |
32| `c` `m` `p` `t` `n` | Sort by CPU / MEM / PID / TIME / name (press again to reverse) |
33| `T` | Toggle tree: sort by value, then group each hot PID with its PPID family |
34| `r` | Reverse sort (highest-first by default for CPU/MEM/TIME) |
35| `/` | Filter (substring on command, user, pid, ppid) |
36| `k` / `K` | Kill selected process (SIGTERM, confirms) |
37| `Space` | Force refresh |
38| `h` / `?` | Help |
39| `q` / `Esc` | Quit |
40
41## Mouse
42
43| Action | Effect |
44|--------|--------|
45| Click process row | Select that process |
46| Click table header (PID / CPU% / MEM% / TIME+ / Command) | Sort by that column (again to reverse) |
47| Scroll wheel | Move selection |
48| Right-click process | Select and confirm kill (SIGTERM) |
49| Click (help / kill dialog) | Close help · cancel kill confirm |
50
51## Architecture
52
53```
54src/
55 monitor.gleam entrypoint
56 app.gleam event loop, keys, refresh
57 ui.gleam layout & rendering (etch)
58 sys.gleam /proc collectors
59 format.gleam bars, sizes, sparklines
60```
61
62Built with [etch](https://hex.pm/packages/etch) for the TUI backend.