diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index 00de3ded..1e53f986 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -666,7 +666,7 @@ namespace Cpu { } width_left -= (gpu.supported_functions.mem_used ? 5 : 0); width_left -= (gpu.supported_functions.mem_total ? 6 : 0); - width_left -= (gpu.supported_functions.pwr_usage ? 5 : 0); + width_left -= (gpu.supported_functions.pwr_usage ? 6 : 0); if (gpu.supported_functions.gpu_utilization) { gpu_meters[i] = Draw::Meter{width_left, "cpu" }; } @@ -756,13 +756,13 @@ namespace Cpu { if (gpu_auto and v_contains(Gpu::shown_panels, i)) continue; out += graphs[i](safeVal(gpus[i].gpu_percent, graph_field), (data_same or redraw)); - if (Gpu::count - Gpu::shown > 1) { + if (Gpu::count - (gpu_auto ? Gpu::shown : 0) > 1) { auto i_str = to_string(i); out += Mv::l(graph_width-1) + Mv::u(graph_height/2) + (graph_width > 5 ? "GPU" : "") + i_str + Mv::d(graph_height/2) + Mv::r(graph_width - 1 - (graph_width > 5)*3 - i_str.size()); } - if (++gpu_drawn < (Gpu::count - Gpu::shown)) + if (++gpu_drawn < Gpu::count - (gpu_auto ? Gpu::shown : 0)) out += Theme::c("div_line") + (Symbols::v_line + Mv::l(1) + Mv::u(1))*graph_height + Mv::r(1) + Mv::d(1); } } @@ -907,7 +907,8 @@ namespace Cpu { out += rjust(to_string(temp), 3) + Theme::c("main_fg") + unit; } if (gpus[i].supported_functions.pwr_usage) { - out += ' ' + Theme::g("cached").at(clamp(safeVal(gpus[i].gpu_percent, "gpu-pwr-totals"s).back(), 0ll, 100ll)) + rjust(to_string(gpus[i].pwr_usage/1000), 3) + Theme::c("main_fg") + 'W'; + out += ' ' + Theme::g("cached").at(clamp(safeVal(gpus[i].gpu_percent, "gpu-pwr-totals"s).back(), 0ll, 100ll)) + + fmt::format("{:>4.{}f}", gpus[i].pwr_usage / 1000.0, gpus[i].pwr_usage < 10'000 ? 2 : gpus[i].pwr_usage < 100'000 ? 1 : 0) + Theme::c("main_fg") + 'W'; } if (cy > b_height - 1) break; @@ -984,12 +985,12 @@ namespace Gpu { Config::getB("cpu_invert_lower"), true }; } - gpu_meter = Draw::Meter{b_width - (show_temps ? 24 : 11), "cpu"}; + gpu_meter = Draw::Meter{b_width - (show_temps ? 25 : 12), "cpu"}; } if (gpu.supported_functions.temp_info) temp_graph = Draw::Graph{6, 1, "temp", gpu.temp, graph_symbol, false, false, gpu.temp_max, -23}; if (gpu.supported_functions.pwr_usage) - pwr_meter = Draw::Meter{b_width - (gpu.supported_functions.pwr_state and gpu.pwr_state != 32 ? 24 : 11), "cached"}; + pwr_meter = Draw::Meter{b_width - (gpu.supported_functions.pwr_state and gpu.pwr_state != 32 ? 25 : 12), "cached"}; if (gpu.supported_functions.mem_utilization) mem_util_graph = Draw::Graph{b_width/2 - 1, 2, "free", gpu.mem_utilization_percent, graph_symbol, 0, 0, 100, 4}; // offset so the graph isn't empty at 0-5% utilization if (gpu.supported_functions.mem_used and gpu.supported_functions.mem_total) @@ -1006,7 +1007,7 @@ namespace Gpu { out += Mv::to(y + graph_up_height + 1, x + 1) + graph_lower(safeVal(gpu.gpu_percent, "gpu-totals"s), (data_same or redraw[index])); out += Mv::to(b_y + 1, b_x + 1) + Theme::c("main_fg") + Fx::b + "GPU " + gpu_meter(safeVal(gpu.gpu_percent, "gpu-totals"s).back()) - + Theme::g("cpu").at(clamp(safeVal(gpu.gpu_percent, "gpu-totals"s).back(), 0ll, 100ll)) + rjust(to_string(safeVal(gpu.gpu_percent, "gpu-totals"s).back()), 4) + Theme::c("main_fg") + '%'; + + Theme::g("cpu").at(clamp(safeVal(gpu.gpu_percent, "gpu-totals"s).back(), 0ll, 100ll)) + rjust(to_string(safeVal(gpu.gpu_percent, "gpu-totals"s).back()), 5) + Theme::c("main_fg") + '%'; //? Temperature graph, I assume the device supports utilization if it supports temperature if (show_temps) { @@ -1027,7 +1028,8 @@ namespace Gpu { //? Power usage meter, power state if (gpu.supported_functions.pwr_usage) { out += Mv::to(b_y + 2, b_x + 1) + Theme::c("main_fg") + Fx::b + "PWR " + pwr_meter(safeVal(gpu.gpu_percent, "gpu-pwr-totals"s).back()) - + Theme::g("cached").at(clamp(safeVal(gpu.gpu_percent, "gpu-pwr-totals"s).back(), 0ll, 100ll)) + rjust(to_string(gpu.pwr_usage/1000), 4) + Theme::c("main_fg") + 'W'; + + Theme::g("cached").at(clamp(safeVal(gpu.gpu_percent, "gpu-pwr-totals"s).back(), 0ll, 100ll)) + + fmt::format("{:>5.{}f}", gpu.pwr_usage / 1000.0, gpu.pwr_usage < 10'000 ? 2 : gpu.pwr_usage < 100'000 ? 1 : 0) + Theme::c("main_fg") + 'W'; if (gpu.supported_functions.pwr_state and gpu.pwr_state != 32) // NVML_PSTATE_UNKNOWN; unsupported or non-nvidia card out += std::string(" P-state: ") + (gpu.pwr_state > 9 ? "" : " ") + 'P' + Theme::g("cached").at(clamp(gpu.pwr_state, 0ll, 100ll)) + to_string(gpu.pwr_state); }