Presets and Layout
Outcome: you can rearrange btop's boxes for the question you are asking — all process list, or all graphs — save the arrangements as presets, and avoid the trap of making a temporary arrangement permanent by accident.
The number keys: boxes on and off
The quickest layout change needs no
menu: the keys 1 to 5 toggle the
boxes — 1 processor, 2 memory, 3
network, 4 processes, 5 graphics (where
present). What remains stretches to
fill the space. Watching a download?
1, 2, 4 off, and the network box
owns the screen. Reading a process list?
The reverse. This is also the practical
answer to a small terminal: btop needs
room, and one box at a time fits where
four will not.
Presets: layouts with names
A preset is a saved arrangement:
which boxes show, in what proportions,
with which graph style. The header
names the active one — preset * for
the standard layout (all boxes, default
settings), or its number. Press p to
cycle forwards through the presets,
Shift+p backwards, or start btop with
one: btop -p 1.
The lab cycled through the three custom presets its copy defines. Preset 1 gives the process list nearly the whole screen — the processor box survives as a strip along the bottom — which is the arrangement for chapter 4's work, when the list is the point. Preset 2, by its definition in the config file, shows processor, memory and network with no process list: the dashboard arrangement. Preset 3 shows processor and network only, and redraws the processor graph in block characters instead of braille:
▐▐▟████│CPU ■■■■■■■■■■■■■■
▐▟█████│C0 ▄▄▄▄▄▄▄▄▄▄▄▄▄▗▗▄
▐▜█████│C1 ▄▄▄▄▄▄▄▄▄▄▄▄▄▗▗▄
Compare chapter 3's fine braille dots: same numbers, heavier ink — the block style stays readable on terminals and fonts where braille glyphs render poorly (chapter 11's tty mode is the extreme of the same idea).
Where presets live
Presets are one line of the config file (chapter 8), and reading the lab's line decodes the whole system:
presets = "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty"
Each space separates one preset;
preset 0 is always the standard layout
and is not written here, so the three
groups are presets 1, 2 and 3. Within
a group, each entry names a box, a size
share, and a graph-symbol set —
default, block, or tty — which is
why preset 3's processor arrived in
blocks and its network in the plainest
symbols. Editing this line (carefully,
keeping the shape) is how a fourth
arrangement of your own is born;
Options' general tab shows the same
line, truncated, as the Presets
entry.
The trap: a preset can become home
Here is the chapter's real lesson, and the lab verified it in its own config file. btop saves its state — including which boxes are shown — when it quits (chapter 8). Quit while a preset is on screen and the preset's box set is what gets written down. The lab cycled to preset 3, quit with Ctrl+C, and later found its config reading:
shown_boxes = "cpu net"
— preset 3's two boxes — and the next
launch duly opened with no memory and
no process box at all, on a screen that
looked broken until the cause was
named. The recovery is easy once known:
press 2 and 4 to bring the missing
boxes back (or fix shown_boxes in
the file), and quit again to save the
restored set. But the principle is
worth keeping: in btop, the state you
quit in is the state you saved, for
layouts as for everything else.
Check: press p until the header shows
a preset number, look at what the
screen kept and what it dropped, then
press the number keys of the missing
boxes and watch them return. You are
ready for the file that remembers all
of it.