Add ability to still show data entries in the legend even if line is disabled.
This commit is contained in:
parent
531e6ed76e
commit
c669b5337c
|
@ -100,6 +100,8 @@ Run using `btm`.
|
|||
|
||||
- `--cpu_default`, `--memory_default`, `--disk_default`, `--temperature_default`, `--network_default`, `--process_default` will select the corresponding widget on startup. By default the process widget is selected.
|
||||
|
||||
- `-s`, `--show_disabled_data` will show data entries in the graph legends even if the lines for that entry are disabled.
|
||||
|
||||
- `-C`, `--config` takes in a file path leading to a TOML file.
|
||||
|
||||
### Config Files
|
||||
|
|
|
@ -23,6 +23,8 @@ default_widget = "cpu_default"
|
|||
#default_widget = "network_default"
|
||||
#default_widget = "process_default"
|
||||
|
||||
show_disabled_data = true
|
||||
|
||||
[colors]
|
||||
# Based on gruvbox: https://github.com/morhetz/gruvbox
|
||||
table_header_color="#458588"
|
||||
|
|
|
@ -155,6 +155,7 @@ pub struct AppConfigFields {
|
|||
pub left_legend: bool,
|
||||
pub show_average_cpu: bool,
|
||||
pub use_current_cpu_total: bool,
|
||||
pub show_disabled_data: bool,
|
||||
}
|
||||
|
||||
/// Network specific
|
||||
|
@ -239,10 +240,12 @@ pub struct App {
|
|||
}
|
||||
|
||||
impl App {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
show_average_cpu: bool, temperature_type: temperature::TemperatureType,
|
||||
update_rate_in_milliseconds: u64, use_dot: bool, left_legend: bool,
|
||||
use_current_cpu_total: bool, current_widget_selected: WidgetPosition,
|
||||
show_disabled_data: bool,
|
||||
) -> App {
|
||||
App {
|
||||
process_sorting_type: processes::ProcessSorting::CPU,
|
||||
|
@ -270,6 +273,7 @@ impl App {
|
|||
update_rate_in_milliseconds,
|
||||
left_legend,
|
||||
use_current_cpu_total,
|
||||
show_disabled_data,
|
||||
},
|
||||
is_expanded: false,
|
||||
cpu_state: CpuState::default(),
|
||||
|
|
|
@ -647,7 +647,9 @@ impl Painter {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(itx, _)| {
|
||||
if app_state.cpu_state.is_showing_tray {
|
||||
if app_state.cpu_state.is_showing_tray
|
||||
|| app_state.app_config_fields.show_disabled_data
|
||||
{
|
||||
true
|
||||
} else {
|
||||
app_state.cpu_state.core_show_vec[*itx]
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -74,6 +74,7 @@ struct ConfigFlags {
|
|||
whole_word: Option<bool>,
|
||||
regex: Option<bool>,
|
||||
default_widget: Option<String>,
|
||||
show_disabled_data: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
|
@ -115,6 +116,7 @@ fn get_matches() -> clap::ArgMatches<'static> {
|
|||
(@arg CASE_SENSITIVE: -S --case_sensitive "Match case when searching by default.")
|
||||
(@arg WHOLE_WORD: -W --whole_word "Match whole word when searching by default.")
|
||||
(@arg REGEX_DEFAULT: -R --regex "Use regex in searching by default.")
|
||||
(@arg SHOW_DISABLED_DATA: -s --show_disabled_data "Show disabled data entries.")
|
||||
(@group DEFAULT_WIDGET =>
|
||||
(@arg CPU_WIDGET: --cpu_default "Selects the CPU widget to be selected by default.")
|
||||
(@arg MEM_WIDGET: --memory_default "Selects the memory widget to be selected by default.")
|
||||
|
@ -144,6 +146,7 @@ fn main() -> error::Result<()> {
|
|||
let left_legend = get_use_left_legend_option(&matches, &config);
|
||||
let use_current_cpu_total = get_use_current_cpu_total_option(&matches, &config);
|
||||
let current_widget_selected = get_default_widget(&matches, &config);
|
||||
let show_disabled_data = get_show_disabled_data_option(&matches, &config);
|
||||
|
||||
// Create "app" struct, which will control most of the program and store settings/state
|
||||
let mut app = app::App::new(
|
||||
|
@ -154,6 +157,7 @@ fn main() -> error::Result<()> {
|
|||
left_legend,
|
||||
use_current_cpu_total,
|
||||
current_widget_selected,
|
||||
show_disabled_data,
|
||||
);
|
||||
|
||||
enable_app_grouping(&matches, &config, &mut app);
|
||||
|
@ -518,6 +522,18 @@ fn get_use_current_cpu_total_option(matches: &clap::ArgMatches<'static>, config:
|
|||
false
|
||||
}
|
||||
|
||||
fn get_show_disabled_data_option(matches: &clap::ArgMatches<'static>, config: &Config) -> bool {
|
||||
if matches.is_present("SHOW_DISABLED_DATA") {
|
||||
return true;
|
||||
} else if let Some(flags) = &config.flags {
|
||||
if let Some(show_disabled_data) = flags.show_disabled_data {
|
||||
return show_disabled_data;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn enable_app_grouping(matches: &clap::ArgMatches<'static>, config: &Config, app: &mut app::App) {
|
||||
if matches.is_present("GROUP_PROCESSES") {
|
||||
app.toggle_grouping();
|
||||
|
|
Loading…
Reference in New Issue