Skip to content

Commit 4a64007

Browse files
ClementTsangjamartin9
authored andcommitted
other: move cpu and memory settings over (ClementTsang#2064)
1 parent 78653dd commit 4a64007

21 files changed

Lines changed: 243 additions & 64 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
needs: pre-job
5252
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
5353
runs-on: ${{ matrix.info.os }}
54-
timeout-minutes: 12
54+
timeout-minutes: 20
5555
strategy:
5656
fail-fast: false
5757
matrix:
@@ -276,7 +276,7 @@ jobs:
276276
}
277277
runs-on: ${{ matrix.info.os }}
278278
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
279-
timeout-minutes: 12
279+
timeout-minutes: 20
280280
steps:
281281
- name: Checkout repository
282282
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ That said, these are more guidelines rather than hard rules, though the project
4848
- [#2062](https://github.com/ClementTsang/bottom/pull/2062): Rename `[network]` to `[network_graph]` in the config file; `[network]` remains valid as an alias.
4949
- [#2062](https://github.com/ClementTsang/bottom/pull/2062): Move network and memory graph config file options from `[flags]` to be under `[network_graph]` and `[memory_graph]`.
5050
- [#2063](https://github.com/ClementTsang/bottom/pull/2063): Move process config file options from `[flags]` to be under `[processes]`.
51+
- [#2064](https://github.com/ClementTsang/bottom/pull/2064): Move CPU config file options from `[flags]` to be under `[cpu]`.
52+
- [#2064](https://github.com/ClementTsang/bottom/pull/2064): Move memory config file options from `[flags]` to be under `[memory_graph]`.
5153

5254
### Other
5355

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CPU
2+
3+
If you want to change some of the default behaviour of the CPU graph widget, you can configure things under the `[cpu]` section.
4+
5+
## Default CPU graph selection
6+
7+
You can configure which CPU graph is shown by default on startup by setting `cpu.default`. Defaults to `"all"`, which
8+
shows all entries.
9+
10+
```toml
11+
[cpu]
12+
# One of "all" (default), "average"/"avg"
13+
default = "average"
14+
```
15+
16+
## Show decimal
17+
18+
You can configure whether CPU usage values are shown with a decimal place by setting `cpu.show_decimal`. Defaults
19+
to `false`.
20+
21+
```toml
22+
[cpu]
23+
show_decimal = true
24+
```
25+
26+
## Hide average CPU entry
27+
28+
You can hide the average CPU entry entirely by setting `cpu.hide_avg_cpu`. Defaults to `false`.
29+
30+
```toml
31+
[cpu]
32+
hide_avg_cpu = true
33+
```
34+
35+
## Place legend on the left
36+
37+
You can place the CPU chart legend on the left side by setting `cpu.left_legend`. Defaults to `false`.
38+
39+
```toml
40+
[cpu]
41+
left_legend = true
42+
```
43+
44+
## Average CPU row
45+
46+
In basic mode, you can give the average CPU entry a dedicated row by setting `cpu.basic_average_cpu_row`. Defaults to `false`.
47+
48+
```toml
49+
[cpu]
50+
basic_average_cpu_row = true
51+
```

docs/content/configuration/config-file/cpu.md

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
# Memory Graph
22

3-
## Settings
3+
If you want to change some of the default behaviour of the memory graph widget, you can configure things under the `[memory_graph]` (or `[memory]`) section.
44

5-
If you want to change some of the default behaviour of the memory graph widget, you can configure some things in the config file.
5+
## Graph legend position
66

7-
| Field | Type | Functionality |
8-
| ----------------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------- |
9-
| `legend_position` | String (one of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]) | Where to place the legend for the memory widget. |
7+
You can change where the legend for the graph is placed within the widget itself (or hidden with `"none"`). The default is `"top-right"`.
8+
9+
```toml
10+
[memory_graph]
11+
# One of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]
12+
legend_position = "top-left"
13+
```
14+
15+
## Collect/show cache memory
16+
17+
On Linux, you can change whether the memory used by [cache/slabs](https://serverfault.com/a/1025189) is collected and
18+
shown. By default, it is `false`.
19+
20+
```toml
21+
[memory_graph]
22+
cache_memory = true
23+
```
24+
25+
## Subtract free-able ARC from memory
26+
27+
If ZFS is detected (note that the `zfs` feature must be enabled if built manually), you can enable `memory_graph.free_arc` to
28+
not count [ARC](https://www.45drives.com/community/articles/zfs-caching/) memory in the RAM usage calculations. Disabled
29+
by default.
30+
31+
```toml
32+
[memory_graph]
33+
free_arc = true
34+
```

docs/mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ nav:
161161
- "General Usage": usage/general-usage.md
162162
- "Basic Mode": usage/basic-mode.md
163163
- "Widgets":
164-
- "CPU Widget": usage/widgets/cpu.md
164+
- "CPU Widget": usage/widgets/cpu-graph.md
165165
- "Memory Graph Widget": usage/widgets/memory-graph.md
166166
- "Network Graph Widget": usage/widgets/network-graph.md
167167
- "Process Widget": usage/widgets/process.md
@@ -174,7 +174,7 @@ nav:
174174
- "Command-line Options": configuration/command-line-options.md
175175
- "Config File":
176176
- configuration/config-file/index.md
177-
- "CPU Widget": configuration/config-file/cpu.md
177+
- "CPU Widget": configuration/config-file/cpu-graph.md
178178
- "Disk Table Widget": configuration/config-file/disk-table.md
179179
- "Memory Graph Widget": configuration/config-file/memory-graph.md
180180
- "Network Graph Widget": configuration/config-file/network-graph.md

schema/nightly/bottom.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,31 @@
152152
"description": "CPU column settings.",
153153
"type": "object",
154154
"properties": {
155+
"basic_average_cpu_row": {
156+
"description": "Whether to give the average CPU entry a dedicated row in basic mode.",
157+
"type": [
158+
"boolean",
159+
"null"
160+
]
161+
},
155162
"default": {
156163
"description": "The default selected entry of the CPU widget.",
157164
"$ref": "#/$defs/CpuDefault"
158165
},
166+
"hide_avg_cpu": {
167+
"description": "Whether to hide the average CPU entry.",
168+
"type": [
169+
"boolean",
170+
"null"
171+
]
172+
},
173+
"left_legend": {
174+
"description": "Whether to put the CPU chart legend on the left side.",
175+
"type": [
176+
"boolean",
177+
"null"
178+
]
179+
},
159180
"show_decimal": {
160181
"description": "Whether to show a decimal place for CPU usage values.",
161182
"type": [
@@ -665,6 +686,20 @@
665686
"description": "Memory-related configuration file options.",
666687
"type": "object",
667688
"properties": {
689+
"cache_memory": {
690+
"description": "Whether to collect and display cache and buffer memory. Not available on Windows.",
691+
"type": [
692+
"boolean",
693+
"null"
694+
]
695+
},
696+
"free_arc": {
697+
"description": "Whether to subtract freeable ARC from memory usage.",
698+
"type": [
699+
"boolean",
700+
"null"
701+
]
702+
},
668703
"legend_position": {
669704
"description": "Where to place the legend for the memory chart widget.",
670705
"type": [
@@ -980,7 +1015,7 @@
9801015
]
9811016
},
9821017
"hide_k_threads": {
983-
"description": "Hide kernel threads from being shown.",
1018+
"description": "Hide kernel threads from being shown. Linux only.",
9841019
"type": [
9851020
"boolean",
9861021
"null"

src/options.rs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,14 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
275275

276276
let use_basic_mode = is_flag_enabled!(basic, args.general, config);
277277
let expanded = is_flag_enabled!(expanded, args.general, config);
278+
278279
#[cfg(feature = "zfs")]
279-
let free_arc = is_flag_enabled!(free_arc, args.memory, config);
280+
let free_arc = enabled_option_with_deprecated!(
281+
args.memory.free_arc,
282+
config,
283+
memory_graph.free_arc,
284+
flags.free_arc,
285+
);
280286

281287
// For processes
282288
let is_grouped = enabled_option_with_deprecated!(
@@ -402,7 +408,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
402408
show_average_cpu: get_show_average_cpu(args, config),
403409
show_cpu_decimal: config_or!(config, cpu.show_decimal, false),
404410
use_dot: is_flag_enabled!(dot_marker, args.general, config),
405-
cpu_left_legend: is_flag_enabled!(cpu_left_legend, args.cpu, config),
411+
cpu_left_legend: enabled_option_with_deprecated!(
412+
args.cpu.cpu_left_legend,
413+
config,
414+
cpu.left_legend,
415+
flags.cpu_left_legend,
416+
),
406417
use_current_cpu_total: enabled_option_with_deprecated!(
407418
args.process.current_usage,
408419
config,
@@ -445,7 +456,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
445456
network_use_binary_prefix,
446457
network_show_packets,
447458
retention_ms,
448-
dedicated_average_row: config_or!(config, flags.average_cpu_row, false),
459+
dedicated_average_row: enabled_option_with_deprecated!(
460+
false,
461+
config,
462+
cpu.basic_average_cpu_row,
463+
flags.average_cpu_row,
464+
),
449465
default_tree_collapse: is_default_tree_collapsed,
450466
#[cfg(feature = "zfs")]
451467
free_arc,
@@ -716,7 +732,12 @@ pub(crate) fn init_app(args: BottomArgs, config: Config) -> Result<(App, BottomL
716732
fn get_widget_layout(
717733
args: &BottomArgs, config: &Config,
718734
) -> OptionResult<(BottomLayout, u64, Option<BottomWidgetType>)> {
719-
let cpu_left_legend = is_flag_enabled!(cpu_left_legend, args.cpu, config);
735+
let cpu_left_legend = enabled_option_with_deprecated!(
736+
args.cpu.cpu_left_legend,
737+
config,
738+
cpu.left_legend,
739+
flags.cpu_left_legend,
740+
);
720741

721742
let (default_widget_type, mut default_widget_count) =
722743
get_default_widget_and_count(args, config)?;
@@ -903,9 +924,12 @@ fn get_temperature(args: &BottomArgs, config: &Config) -> OptionResult<Temperatu
903924
fn get_show_average_cpu(args: &BottomArgs, config: &Config) -> bool {
904925
if args.cpu.hide_avg_cpu {
905926
return false;
927+
} else if let Some(cpu) = &config.cpu {
928+
return !cpu.hide_avg_cpu.unwrap_or(false);
906929
} else if let Some(flags) = &config.flags {
907-
if let Some(avg_cpu) = flags.hide_avg_cpu {
908-
return !avg_cpu;
930+
if let Some(hide) = flags.hide_avg_cpu {
931+
deprecated_warning("hide_avg_cpu", "cpu.hide_avg_cpu");
932+
return !hide;
909933
}
910934
}
911935

@@ -1057,7 +1081,12 @@ fn get_enable_gpu(_: &BottomArgs, _: &Config) -> bool {
10571081

10581082
#[cfg(not(target_os = "windows"))]
10591083
fn get_enable_cache_memory(args: &BottomArgs, config: &Config) -> bool {
1060-
is_flag_enabled!(enable_cache_memory, args.memory, config)
1084+
enabled_option_with_deprecated!(
1085+
args.memory.enable_cache_memory,
1086+
config,
1087+
memory_graph.cache_memory,
1088+
flags.enable_cache_memory,
1089+
)
10611090
}
10621091

10631092
#[cfg(target_os = "windows")]

src/options/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct Config {
3636
pub(crate) temperature_graph: Option<TempGraphConfig>,
3737
#[serde(alias = "network")]
3838
pub(crate) network_graph: Option<NetworkGraphConfig>,
39+
#[serde(alias = "memory")]
3940
pub(crate) memory_graph: Option<MemoryGraphConfig>,
4041
pub(crate) cpu: Option<CpuConfig>,
4142
}

0 commit comments

Comments
 (0)