Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/content/configuration/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ see information on these options by running `btm -h`, or run `btm --help` to dis
| --------------------------------- | ---------------------------------------------------- |
| `--autohide_time` | Temporarily shows the time scale in graphs. |
| `-b, --basic` | Hides graphs and uses a more basic look. |
| `--clean` | Hides borders and use a cleaner look. |
| `-C, --config <CONFIG PATH>` | Sets the location of the config file. |
| `-t, --default_time_value <TIME>` | Default time value for graphs. |
| `--default_widget_count <N>` | Sets the N'th selected widget type as the default. |
Expand Down
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct AppConfigFields {
pub use_current_cpu_total: bool,
pub unnormalized_cpu: bool,
pub use_basic_mode: bool,
pub use_clean_mode: bool,
pub default_time_value: u64,
pub time_interval: u64,
pub hide_time: bool,
Expand Down
1 change: 1 addition & 0 deletions src/canvas/components/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ mod test {
table_gap: 1,
left_to_right: false,
is_basic: false,
is_clean: false,
show_table_scroll_position: true,
show_current_entry_when_unfocused: false,
};
Expand Down
4 changes: 3 additions & 1 deletion src/canvas/components/data_table/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ where
}
};

if !self.props.is_basic {
if self.props.is_clean {
Block::default().borders(Borders::NONE)
} else if !self.props.is_basic {
let block = Block::default()
.borders(Borders::ALL)
.border_style(border_style);
Expand Down
3 changes: 3 additions & 0 deletions src/canvas/components/data_table/props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub struct DataTableProps {
/// Whether this table is a basic table. This affects the borders.
pub is_basic: bool,

/// Whether this table is a clean table. This affects the borders.
pub is_clean: bool,

/// Whether to show the table scroll position.
pub show_table_scroll_position: bool,

Expand Down
1 change: 1 addition & 0 deletions src/canvas/components/data_table/sortable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ mod test {
table_gap: 1,
left_to_right: false,
is_basic: false,
is_clean: false,
show_table_scroll_position: true,
show_current_entry_when_unfocused: false,
};
Expand Down
13 changes: 12 additions & 1 deletion src/canvas/components/time_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub struct TimeGraph<'a> {
/// Whether this graph is expanded.
pub is_expanded: bool,

/// Whether this graph is clean. Without borders.
pub is_clean: bool,

/// The title style.
pub title_style: Style,

Expand Down Expand Up @@ -135,9 +138,16 @@ impl<'a> TimeGraph<'a> {
// This is some ugly manual loop unswitching. Maybe unnecessary.
// TODO: Optimize this step. Cut out unneeded points.
let data = graph_data.iter().map(create_dataset).collect();

let borders = if self.is_clean {
Borders::RIGHT
} else {
Borders::ALL
};

let block = Block::default()
.title(self.generate_title(draw_loc))
.borders(Borders::ALL)
.borders(borders)
.border_style(self.border_style);

f.render_widget(
Expand Down Expand Up @@ -207,6 +217,7 @@ mod test {
graph_style: Style::default().fg(Color::Red),
border_style: Style::default().fg(Color::Blue),
is_expanded: false,
is_clean: false,
title_style: Style::default().fg(Color::Cyan),
legend_position: None,
legend_constraints: None,
Expand Down
1 change: 1 addition & 0 deletions src/canvas/widgets/cpu_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl Painter {
graph_style: self.colours.graph_style,
border_style,
title,
is_clean: app_state.app_config_fields.use_clean_mode,
is_expanded: app_state.is_expanded,
title_style: self.colours.widget_title_style,
legend_position: None,
Expand Down
1 change: 1 addition & 0 deletions src/canvas/widgets/mem_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl Painter {
graph_style: self.colours.graph_style,
border_style,
title: " Memory ".into(),
is_clean: app_state.app_config_fields.use_clean_mode,
is_expanded: app_state.is_expanded,
title_style: self.colours.widget_title_style,
legend_position: app_state.app_config_fields.memory_legend_position,
Expand Down
1 change: 1 addition & 0 deletions src/canvas/widgets/network_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl Painter {
y_labels: &y_labels,
graph_style: self.colours.graph_style,
border_style,
is_clean: app_state.app_config_fields.use_clean_mode,
title: " Network ".into(),
is_expanded: app_state.is_expanded,
title_style: self.colours.widget_title_style,
Expand Down
2 changes: 2 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub fn init_app(

let use_basic_mode = is_flag_enabled!(basic, matches, config);
let expanded = is_flag_enabled!(expanded, matches, config);
let use_clean_mode = is_flag_enabled!(clean, matches, config);

// For processes
let is_grouped = is_flag_enabled!(group_processes, matches, config);
Expand Down Expand Up @@ -141,6 +142,7 @@ pub fn init_app(
use_current_cpu_total: is_flag_enabled!(current_usage, matches, config),
unnormalized_cpu: is_flag_enabled!(unnormalized_cpu, matches, config),
use_basic_mode,
use_clean_mode,
default_time_value,
time_interval: get_time_interval(matches, config, retention_ms)
.context("Update 'time_delta' in your config file.")?,
Expand Down
27 changes: 18 additions & 9 deletions src/options/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ fn general_args(cmd: Command) -> Command {
.help("Hides graphs and uses a more basic look.")
.long_help("Hides graphs and uses a more basic look, largely inspired by htop's design.");

let clean = Arg::new("clean")
.long("clean")
.action(ArgAction::SetTrue)
.help("Hides borders and use a cleaner look.")
.long_help(
"Hides borders and use a cleaner look. Keeping only the separator borders visible.",
);

let config_location = Arg::new("config_location")
.short('C')
.long("config")
Expand All @@ -85,6 +93,12 @@ fn general_args(cmd: Command) -> Command {
)
.value_hint(ValueHint::AnyPath);

let disable_click = Arg::new("disable_click")
.long("disable_click")
.action(ArgAction::SetTrue)
.help("Disables mouse clicks.")
.long_help("Disables mouse clicks from interacting with bottom.");

let default_time_value = Arg::new("default_time_value")
.short('t')
.long("default_time_value")
Expand Down Expand Up @@ -155,12 +169,6 @@ fn general_args(cmd: Command) -> Command {
"battery",
]);

let disable_click = Arg::new("disable_click")
.long("disable_click")
.action(ArgAction::SetTrue)
.help("Disables mouse clicks.")
.long_help("Disables mouse clicks from interacting with bottom.");

// TODO: Change this to accept a string with the type of marker.
let dot_marker = Arg::new("dot_marker")
.short('m')
Expand Down Expand Up @@ -231,6 +239,7 @@ fn general_args(cmd: Command) -> Command {
cmd.args(args![
autohide_time,
basic,
clean,
config_location,
default_widget_count,
default_time_value,
Expand Down Expand Up @@ -540,11 +549,11 @@ pub fn build_app() -> Command {
const TEMPLATE: &str = indoc! {
"{name} {version}
{author}

{about}

{usage-heading} {usage}

{all-args}"
};
const USAGE: &str = "btm [OPTIONS]";
Expand Down
1 change: 1 addition & 0 deletions src/options/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub(crate) struct ConfigFlags {
pub(crate) whole_word: Option<bool>,
pub(crate) regex: Option<bool>,
pub(crate) basic: Option<bool>,
pub(crate) clean: Option<bool>,
pub(crate) default_time_value: Option<StringOrNum>,
pub(crate) time_delta: Option<StringOrNum>,
pub(crate) autohide_time: Option<bool>,
Expand Down
1 change: 1 addition & 0 deletions src/widgets/cpu_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl CpuWidgetState {
table_gap: config.table_gap,
left_to_right: false,
is_basic: false,
is_clean: config.use_clean_mode,
show_table_scroll_position: false, // TODO: Should this be possible?
show_current_entry_when_unfocused: true,
};
Expand Down
1 change: 1 addition & 0 deletions src/widgets/disk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl DiskTableWidget {
title: Some(" Disks ".into()),
table_gap: config.table_gap,
left_to_right: true,
is_clean: config.use_clean_mode,
is_basic: config.use_basic_mode,
show_table_scroll_position: config.show_table_scroll_position,
show_current_entry_when_unfocused: false,
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/process_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl ProcWidgetState {
table_gap: config.table_gap,
left_to_right: true,
is_basic: false,
is_clean: false,
show_table_scroll_position: false,
show_current_entry_when_unfocused: false,
};
Expand All @@ -216,6 +217,7 @@ impl ProcWidgetState {
table_gap: config.table_gap,
left_to_right: true,
is_basic: config.use_basic_mode,
is_clean: config.use_clean_mode,
show_table_scroll_position: config.show_table_scroll_position,
show_current_entry_when_unfocused: false,
};
Expand Down
1 change: 1 addition & 0 deletions src/widgets/temperature_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl TempWidgetState {
table_gap: config.table_gap,
left_to_right: false,
is_basic: config.use_basic_mode,
is_clean: config.use_clean_mode,
show_table_scroll_position: config.show_table_scroll_position,
show_current_entry_when_unfocused: false,
},
Expand Down