diff options
author | Jakob P. Liljenberg <admin@qvantnet.com> | 2024-01-03 16:34:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 16:34:01 +0100 |
commit | ef788efc536733a441949dab854b0a6bea5ef33e (patch) | |
tree | 4a27a7212369425705973fc29f9c8feff00b00ba /src/btop_config.cpp | |
parent | c90e3f9b1508f55d281495468297df409f974eb0 (diff) | |
parent | a29545c4079e9bc5203e09965ac03fabe975bd7e (diff) |
Merge branch 'main' into lldb-term-size
Diffstat (limited to 'src/btop_config.cpp')
-rw-r--r-- | src/btop_config.cpp | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/src/btop_config.cpp b/src/btop_config.cpp index fc71e41..6ddfd43 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -21,6 +21,7 @@ tab-size = 4 #include <fstream> #include <ranges> #include <string_view> +#include <utility> #include <fmt/core.h> @@ -73,14 +74,16 @@ namespace Config { "#* Note that \"tty\" only has half the horizontal resolution of the other two, so will show a shorter historical view."}, {"graph_symbol_cpu", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."}, - +#ifdef GPU_SUPPORT + {"graph_symbol_gpu", "# Graph symbol to use for graphs in gpu box, \"default\", \"braille\", \"block\" or \"tty\"."}, +#endif {"graph_symbol_mem", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."}, {"graph_symbol_net", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."}, {"graph_symbol_proc", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."}, - {"shown_boxes", "#* Manually set which boxes to show. Available values are \"cpu mem net proc\", separate values with whitespace."}, + {"shown_boxes", "#* Manually set which boxes to show. Available values are \"cpu mem net proc\" and \"gpu0\" through \"gpu5\", separate values with whitespace."}, {"update_ms", "#* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs."}, @@ -114,7 +117,9 @@ namespace Config { {"cpu_graph_lower", "#* Sets the CPU stat shown in lower half of the CPU graph, \"total\" is always available.\n" "#* Select from a list of detected attributes from the options menu."}, - + #ifdef GPU_SUPPORT + {"show_gpu_info", "#* If gpu info should be shown in the cpu box. Available values = \"Auto\", \"On\" and \"Off\"."}, + #endif {"cpu_invert_lower", "#* Toggles if the lower CPU graph should be inverted."}, {"cpu_single_graph", "#* Set to True to completely disable the lower CPU graph."}, @@ -194,21 +199,36 @@ namespace Config { {"selected_battery", "#* Which battery to use if multiple are present. \"Auto\" for auto detection."}, {"log_level", "#* Set loglevel for \"~/.config/btop/btop.log\" levels are: \"ERROR\" \"WARNING\" \"INFO\" \"DEBUG\".\n" - "#* The level set includes all lower levels, i.e. \"DEBUG\" will show all logging info."} + "#* The level set includes all lower levels, i.e. \"DEBUG\" will show all logging info."}, + #ifdef GPU_SUPPORT + + {"nvml_measure_pcie_speeds", + "#* Measure PCIe throughput on NVIDIA cards, may impact performance on certain cards."}, + + {"gpu_mirror_graph", "#* Horizontally mirror the GPU graph."}, + + {"custom_gpu_name0", "#* Custom gpu0 model name, empty string to disable."}, + {"custom_gpu_name1", "#* Custom gpu1 model name, empty string to disable."}, + {"custom_gpu_name2", "#* Custom gpu2 model name, empty string to disable."}, + {"custom_gpu_name3", "#* Custom gpu3 model name, empty string to disable."}, + {"custom_gpu_name4", "#* Custom gpu4 model name, empty string to disable."}, + {"custom_gpu_name5", "#* Custom gpu5 model name, empty string to disable."}, + #endif }; - unordered_flat_map<std::string_view, string> strings = { + std::unordered_map<std::string_view, string> strings = { {"color_theme", "Default"}, {"shown_boxes", "cpu mem net proc"}, {"graph_symbol", "braille"}, {"presets", "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty"}, {"graph_symbol_cpu", "default"}, + {"graph_symbol_gpu", "default"}, {"graph_symbol_mem", "default"}, {"graph_symbol_net", "default"}, {"graph_symbol_proc", "default"}, {"proc_sorting", "cpu lazy"}, - {"cpu_graph_upper", "total"}, - {"cpu_graph_lower", "total"}, + {"cpu_graph_upper", "Auto"}, + {"cpu_graph_lower", "Auto"}, {"cpu_sensor", "Auto"}, {"selected_battery", "Auto"}, {"cpu_core_map", ""}, @@ -222,10 +242,19 @@ namespace Config { {"proc_filter", ""}, {"proc_command", ""}, {"selected_name", ""}, + #ifdef GPU_SUPPORT + {"custom_gpu_name0", ""}, + {"custom_gpu_name1", ""}, + {"custom_gpu_name2", ""}, + {"custom_gpu_name3", ""}, + {"custom_gpu_name4", ""}, + {"custom_gpu_name5", ""}, + {"show_gpu_info", "Auto"} + #endif }; - unordered_flat_map<std::string_view, string> stringsTmp; + std::unordered_map<std::string_view, string> stringsTmp; - unordered_flat_map<std::string_view, bool> bools = { + std::unordered_map<std::string_view, bool> bools = { {"theme_background", true}, {"truecolor", true}, {"rounded_corners", true}, @@ -271,10 +300,14 @@ namespace Config { {"show_detailed", false}, {"proc_filtering", false}, {"proc_aggregate", false}, + #ifdef GPU_SUPPORT + {"nvml_measure_pcie_speeds", true}, + {"gpu_mirror_graph", true}, + #endif }; - unordered_flat_map<std::string_view, bool> boolsTmp; + std::unordered_map<std::string_view, bool> boolsTmp; - unordered_flat_map<std::string_view, int> ints = { + std::unordered_map<std::string_view, int> ints = { {"update_ms", 2000}, {"net_download", 100}, {"net_upload", 100}, @@ -285,7 +318,7 @@ namespace Config { {"proc_selected", 0}, {"proc_last_selected", 0}, }; - unordered_flat_map<std::string_view, int> intsTmp; + std::unordered_map<std::string_view, int> intsTmp; bool _locked(const std::string_view name) { atomic_wait(writelock, true); @@ -321,7 +354,7 @@ namespace Config { validError = "Malformatted preset in config value presets!"; return false; } - if (not is_in(vals.at(0), "cpu", "mem", "net", "proc")) { + if (not is_in(vals.at(0), "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4", "gpu5")) { validError = "Invalid box name in config value presets!"; return false; } @@ -417,6 +450,11 @@ namespace Config { else if (name == "shown_boxes" and not value.empty() and not check_boxes(value)) validError = "Invalid box name(s) in shown_boxes!"; + #ifdef GPU_SUPPORT + else if (name == "show_gpu_info" and not v_contains(show_gpu_values, value)) + validError = "Invalid value for show_gpu_info: " + value; + #endif + else if (name == "presets" and not presetsValid(value)) return false; @@ -519,6 +557,13 @@ namespace Config { auto new_boxes = ssplit(boxes); for (auto& box : new_boxes) { if (not v_contains(valid_boxes, box)) return false; + #ifdef GPU_SUPPORT + if (box.starts_with("gpu")) { + size_t gpu_num = stoi(box.substr(3)); + if (gpu_num == 0) gpu_num = 5; + if (std::cmp_greater(gpu_num, Gpu::gpu_names.size())) return false; + } + #endif } current_boxes = std::move(new_boxes); return true; |