From dd003101a0626968a6a79eff79e800441973c570 Mon Sep 17 00:00:00 2001 From: Justin Martin Date: Sun, 16 Oct 2022 00:08:38 -0400 Subject: [PATCH] enable gpu mem cli and update docs for arc/gpu mem (#836) --- docs/content/configuration/command-line-flags.md | 1 + docs/content/configuration/config-file/flags.md | 1 + docs/content/configuration/config-file/theming.md | 2 ++ sample_configs/default_config.toml | 8 +++++++- src/constants.rs | 2 ++ src/options.rs | 7 +------ 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/content/configuration/command-line-flags.md b/docs/content/configuration/command-line-flags.md index b5d6d3d3..3247c482 100644 --- a/docs/content/configuration/command-line-flags.md +++ b/docs/content/configuration/command-line-flags.md @@ -43,3 +43,4 @@ The following flags can be provided to bottom in the command line to change the | `--use_old_network_legend` | DEPRECATED - uses the older network legend. | | `-V, --version` | Prints version information. | | `-W, --whole_word` | Enables whole-word matching by default. | +| `--enable_gpu_memory` | Enable collecting and displaying GPU memory usage. | diff --git a/docs/content/configuration/config-file/flags.md b/docs/content/configuration/config-file/flags.md index 93f75ac4..93c71379 100644 --- a/docs/content/configuration/config-file/flags.md +++ b/docs/content/configuration/config-file/flags.md @@ -36,3 +36,4 @@ Most of the [command line flags](../../command-line-flags) have config file equi | `network_use_binary_prefix` | Boolean | Displays the network widget with binary prefixes. | | `network_use_bytes` | Boolean | Displays the network widget using bytes. | | `network_use_log` | Boolean | Displays the network widget with a log scale. | +| `enable_gpu_memory` | Boolean | Shows the GPU memory widget. | diff --git a/docs/content/configuration/config-file/theming.md b/docs/content/configuration/config-file/theming.md index cbb46f85..4d9e03f1 100644 --- a/docs/content/configuration/config-file/theming.md +++ b/docs/content/configuration/config-file/theming.md @@ -29,3 +29,5 @@ Supported named colours are one of the following strings: `Reset, Black, Red, Gr | High battery level colour | The colour used for a high battery level (100% to 50%) | `high_battery_color="green"` | | Medium battery level colour | The colour used for a medium battery level (50% to 10%) | `medium_battery_color="yellow"` | | Low battery level colour | The colour used for a low battery level (10% to 0%) | `low_battery_color="red"` | +| GPU colour per gpu | Colour of each gpu. Read in order. | `gpu_core_colors=["#ffffff", "white", "255, 255, 255"]` | +| ARC | The colour ARC will use | `arc_color="#ffffff"` | diff --git a/sample_configs/default_config.toml b/sample_configs/default_config.toml index 1e2d56a4..74b30da3 100644 --- a/sample_configs/default_config.toml +++ b/sample_configs/default_config.toml @@ -69,6 +69,8 @@ #network_use_log = false # Hides advanced options to stop a process on Unix-like systems. #disable_advanced_kill = false +# Shows GPU(s) memory +#enable_gpu_memory = false # These are all the components that support custom theming. Note that colour support # will depend on terminal support. @@ -86,6 +88,10 @@ #ram_color="LightMagenta" # Represents the colour SWAP will use in the memory legend and graph. #swap_color="LightYellow" +# Represents the colour ARC will use in the memory legend and graph. +#arc_color="LightCyan" +# Represents the colour the GPU will use in the memory legend and graph. +#gpu_core_colors=["LightGreen", "LightBlue", "LightRed", "Cyan", "Green", "Blue", "Red"] # Represents the colour rx will use in the network legend and graph. #rx_color="LightCyan" # Represents the colour tx will use in the network legend and graph. @@ -113,7 +119,7 @@ # [[row.child.child]] represents a widget. # # All widgets must have the type value set to one of ["cpu", "mem", "proc", "net", "temp", "disk", "empty"]. -# All layout components have a ratio value - if this is not set, then it defaults to 1. +# All layout components have a ratio value - if this is not set, then it defaults to 1. # The default widget layout: #[[row]] # ratio=30 diff --git a/src/constants.rs b/src/constants.rs index 3f095c5c..afa0b80f 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -546,6 +546,8 @@ pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. A #network_use_log = false # Hides advanced options to stop a process on Unix-like systems. #disable_advanced_kill = false +# Shows GPU(s) memory +#enable_gpu_memory = false # These are all the components that support custom theming. Note that colour support # will depend on terminal support. diff --git a/src/options.rs b/src/options.rs index c2bac1c9..5213dcf0 100644 --- a/src/options.rs +++ b/src/options.rs @@ -380,12 +380,7 @@ pub fn build_app( let used_widgets = UsedWidgets { use_cpu: used_widget_set.get(&Cpu).is_some() || used_widget_set.get(&BasicCpu).is_some(), use_mem, - use_gpu: use_mem - && config - .flags - .as_ref() - .and_then(|f| f.enable_gpu_memory) - .unwrap_or(false), + use_gpu: use_mem && get_enable_gpu_memory(matches, config), use_net: used_widget_set.get(&Net).is_some() || used_widget_set.get(&BasicNet).is_some(), use_proc: used_widget_set.get(&Proc).is_some(), use_disk: used_widget_set.get(&Disk).is_some(),