mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 06:35:07 +02:00
bug: [skip travis] Add a better check for default colors in the config file
This commit is contained in:
parent
6ef1d66b2b
commit
99d04029f0
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -86,6 +86,7 @@
|
|||||||
"regexes",
|
"regexes",
|
||||||
"rsplitn",
|
"rsplitn",
|
||||||
"runlevel",
|
"runlevel",
|
||||||
|
"rustflags",
|
||||||
"rustfmt",
|
"rustfmt",
|
||||||
"shilangyu",
|
"shilangyu",
|
||||||
"softirq",
|
"softirq",
|
||||||
|
@ -355,7 +355,7 @@ pub const OLD_CONFIG_TEXT: &str = r##"# This is a default config file for bottom
|
|||||||
# This group of options represents a command-line flag/option. Flags explicitly
|
# This group of options represents a command-line flag/option. Flags explicitly
|
||||||
# added when running (ie: btm -a) will override this config file if an option
|
# added when running (ie: btm -a) will override this config file if an option
|
||||||
# is also set here.
|
# is also set here.
|
||||||
[flags]
|
#[flags]
|
||||||
# Whether to hide the average cpu entry.
|
# Whether to hide the average cpu entry.
|
||||||
#hide_avg_cpu = false
|
#hide_avg_cpu = false
|
||||||
# Whether to use dot markers rather than braille.
|
# Whether to use dot markers rather than braille.
|
||||||
@ -405,7 +405,7 @@ pub const OLD_CONFIG_TEXT: &str = r##"# This is a default config file for bottom
|
|||||||
|
|
||||||
# These are all the components that support custom theming. Note that colour support
|
# These are all the components that support custom theming. Note that colour support
|
||||||
# will depend on terminal support.
|
# will depend on terminal support.
|
||||||
[colors]
|
#[colors]
|
||||||
# Represents the colour of table headers (processes, CPU, disks, temperature).
|
# Represents the colour of table headers (processes, CPU, disks, temperature).
|
||||||
#table_header_color="LightBlue"
|
#table_header_color="LightBlue"
|
||||||
# Represents the colour of the label each widget has.
|
# Represents the colour of the label each widget has.
|
||||||
|
@ -192,6 +192,18 @@ pub struct ConfigColours {
|
|||||||
pub low_battery_color: Option<String>,
|
pub low_battery_color: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ConfigColours {
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
if let Ok(serialized_string) = toml::to_string(self) {
|
||||||
|
if !serialized_string.is_empty() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct IgnoreList {
|
pub struct IgnoreList {
|
||||||
pub is_list_ignored: bool,
|
pub is_list_ignored: bool,
|
||||||
@ -918,9 +930,16 @@ pub fn get_color_scheme(
|
|||||||
if let Some(color) = matches.value_of("color") {
|
if let Some(color) = matches.value_of("color") {
|
||||||
// Highest priority is always command line flags...
|
// Highest priority is always command line flags...
|
||||||
return ColourScheme::from_str(color);
|
return ColourScheme::from_str(color);
|
||||||
} else if config.colors.is_some() {
|
} else if let Some(colors) = &config.colors {
|
||||||
// Then, give priority to custom colours...
|
if !colors.is_empty() {
|
||||||
return Ok(ColourScheme::Custom);
|
// Then, give priority to custom colours...
|
||||||
|
return Ok(ColourScheme::Custom);
|
||||||
|
} else if let Some(flags) = &config.flags {
|
||||||
|
// Last priority is config file flags...
|
||||||
|
if let Some(color) = &flags.color {
|
||||||
|
return ColourScheme::from_str(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if let Some(flags) = &config.flags {
|
} else if let Some(flags) = &config.flags {
|
||||||
// Last priority is config file flags...
|
// Last priority is config file flags...
|
||||||
if let Some(color) = &flags.color {
|
if let Some(color) = &flags.color {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user