other: clean up some strings (#904)
* other: clean up some strings * formatting
This commit is contained in:
parent
6a0bf10760
commit
63df220a38
|
@ -235,6 +235,7 @@ dependencies = [
|
|||
"mach2",
|
||||
"nvml-wrapper",
|
||||
"once_cell",
|
||||
"phf",
|
||||
"predicates",
|
||||
"procfs",
|
||||
"regex",
|
||||
|
@ -1289,6 +1290,48 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c"
|
||||
dependencies = [
|
||||
"phf_macros",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_macros"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92aacdc5f16768709a569e913f7451034034178b05bdc8acda226659a3dccc66"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
|
@ -1375,6 +1418,21 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.5.2"
|
||||
|
@ -1550,6 +1608,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.6"
|
||||
|
|
|
@ -79,6 +79,7 @@ indexmap = "1.8.1"
|
|||
itertools = "0.10.3"
|
||||
kstring = { version = "2.0.0", features = ["arc"] }
|
||||
log = { version = "0.4.16", optional = true }
|
||||
phf = { version = "0.11", features = ["macros"] }
|
||||
nvml-wrapper = { version = "0.8.0", optional = true }
|
||||
once_cell = "1.5.2"
|
||||
regex = "1.5.5"
|
||||
|
|
|
@ -3,13 +3,10 @@
|
|||
use std::time::Instant;
|
||||
|
||||
use futures::join;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use fxhash::FxHashMap;
|
||||
|
||||
#[cfg(feature = "battery")]
|
||||
use starship_battery::{Battery, Manager};
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
use sysinfo::{System, SystemExt};
|
||||
|
||||
|
|
|
@ -134,9 +134,10 @@ fn main() -> Result<()> {
|
|||
#[cfg(target_os = "freebsd")]
|
||||
let _stderr_fd = {
|
||||
// A really ugly band-aid to suppress stderr warnings on FreeBSD due to sysinfo.
|
||||
use filedescriptor::{FileDescriptor, StdioDescriptor};
|
||||
use std::fs::OpenOptions;
|
||||
|
||||
use filedescriptor::{FileDescriptor, StdioDescriptor};
|
||||
|
||||
let path = OpenOptions::new().write(true).open("/dev/null")?;
|
||||
FileDescriptor::redirect_stdio(&path, StdioDescriptor::Stderr)?
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::Context;
|
||||
use colour_utils::*;
|
||||
use tui::style::{Color, Style};
|
||||
|
@ -45,15 +47,13 @@ impl Default for CanvasColours {
|
|||
CanvasColours {
|
||||
currently_selected_text_colour: Color::Black,
|
||||
currently_selected_bg_colour: Color::Cyan,
|
||||
currently_selected_text_style: Style::default()
|
||||
.fg(Color::Black)
|
||||
.bg(STANDARD_HIGHLIGHT_COLOUR),
|
||||
table_header_style: Style::default().fg(STANDARD_HIGHLIGHT_COLOUR),
|
||||
ram_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||
arc_style: Style::default().fg(STANDARD_THIRD_COLOUR),
|
||||
currently_selected_text_style: Style::default().fg(Color::Black).bg(HIGHLIGHT_COLOUR),
|
||||
table_header_style: Style::default().fg(HIGHLIGHT_COLOUR),
|
||||
ram_style: Style::default().fg(FIRST_COLOUR),
|
||||
swap_style: Style::default().fg(SECOND_COLOUR),
|
||||
arc_style: Style::default().fg(THIRD_COLOUR),
|
||||
gpu_colour_styles: vec![
|
||||
Style::default().fg(STANDARD_FOURTH_COLOUR),
|
||||
Style::default().fg(FOURTH_COLOUR),
|
||||
Style::default().fg(Color::LightBlue),
|
||||
Style::default().fg(Color::LightRed),
|
||||
Style::default().fg(Color::Cyan),
|
||||
|
@ -61,10 +61,10 @@ impl Default for CanvasColours {
|
|||
Style::default().fg(Color::Blue),
|
||||
Style::default().fg(Color::Red),
|
||||
],
|
||||
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||
total_rx_style: Style::default().fg(STANDARD_THIRD_COLOUR),
|
||||
total_tx_style: Style::default().fg(STANDARD_FOURTH_COLOUR),
|
||||
rx_style: Style::default().fg(FIRST_COLOUR),
|
||||
tx_style: Style::default().fg(SECOND_COLOUR),
|
||||
total_rx_style: Style::default().fg(THIRD_COLOUR),
|
||||
total_tx_style: Style::default().fg(FOURTH_COLOUR),
|
||||
all_colour_style: Style::default().fg(ALL_COLOUR),
|
||||
avg_colour_style: Style::default().fg(AVG_COLOUR),
|
||||
cpu_colour_styles: vec![
|
||||
|
@ -80,7 +80,7 @@ impl Default for CanvasColours {
|
|||
Style::default().fg(Color::Red),
|
||||
],
|
||||
border_style: Style::default().fg(text_colour),
|
||||
highlighted_border_style: Style::default().fg(STANDARD_HIGHLIGHT_COLOUR),
|
||||
highlighted_border_style: Style::default().fg(HIGHLIGHT_COLOUR),
|
||||
text_style: Style::default().fg(text_colour),
|
||||
widget_title_style: Style::default().fg(text_colour),
|
||||
graph_style: Style::default().fg(text_colour),
|
||||
|
@ -283,7 +283,7 @@ impl CanvasColours {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_gpu_colours(&mut self, colours: &[String]) -> error::Result<()> {
|
||||
pub fn set_gpu_colours(&mut self, colours: &[Cow<'static, str>]) -> error::Result<()> {
|
||||
self.gpu_colour_styles = colours
|
||||
.iter()
|
||||
.map(|colour| get_style_from_config(colour))
|
||||
|
@ -321,7 +321,7 @@ impl CanvasColours {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_cpu_colours(&mut self, colours: &[String]) -> error::Result<()> {
|
||||
pub fn set_cpu_colours(&mut self, colours: &[Cow<'static, str>]) -> error::Result<()> {
|
||||
self.cpu_colour_styles = colours
|
||||
.iter()
|
||||
.map(|colour| get_style_from_config(colour))
|
||||
|
|
|
@ -1,44 +1,35 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use tui::style::{Color, Style};
|
||||
|
||||
use crate::utils::error;
|
||||
|
||||
// Approx, good enough for use (also Clippy gets mad if it's too long)
|
||||
pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta;
|
||||
pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;
|
||||
pub const STANDARD_THIRD_COLOUR: Color = Color::LightCyan;
|
||||
pub const STANDARD_FOURTH_COLOUR: Color = Color::LightGreen;
|
||||
pub const STANDARD_HIGHLIGHT_COLOUR: Color = Color::LightBlue;
|
||||
pub const FIRST_COLOUR: Color = Color::LightMagenta;
|
||||
pub const SECOND_COLOUR: Color = Color::LightYellow;
|
||||
pub const THIRD_COLOUR: Color = Color::LightCyan;
|
||||
pub const FOURTH_COLOUR: Color = Color::LightGreen;
|
||||
pub const HIGHLIGHT_COLOUR: Color = Color::LightBlue;
|
||||
pub const AVG_COLOUR: Color = Color::Red;
|
||||
pub const ALL_COLOUR: Color = Color::Green;
|
||||
|
||||
static COLOR_NAME_LOOKUP_TABLE: Lazy<HashMap<&'static str, Color>> = Lazy::new(|| {
|
||||
[
|
||||
("reset", Color::Reset),
|
||||
("black", Color::Black),
|
||||
("red", Color::Red),
|
||||
("green", Color::Green),
|
||||
("yellow", Color::Yellow),
|
||||
("blue", Color::Blue),
|
||||
("magenta", Color::Magenta),
|
||||
("cyan", Color::Cyan),
|
||||
("gray", Color::Gray),
|
||||
("grey", Color::Gray),
|
||||
("darkgray", Color::DarkGray),
|
||||
("lightred", Color::LightRed),
|
||||
("lightgreen", Color::LightGreen),
|
||||
("lightyellow", Color::LightYellow),
|
||||
("lightblue", Color::LightBlue),
|
||||
("lightmagenta", Color::LightMagenta),
|
||||
("lightcyan", Color::LightCyan),
|
||||
("white", Color::White),
|
||||
]
|
||||
.iter()
|
||||
.copied()
|
||||
.collect()
|
||||
});
|
||||
static COLOR_LOOKUP_TABLE: phf::Map<&'static str, Color> = phf::phf_map! {
|
||||
"reset" => Color::Reset,
|
||||
"black" => Color::Black,
|
||||
"red" => Color::Red,
|
||||
"green" => Color::Green,
|
||||
"yellow" => Color::Yellow,
|
||||
"blue" => Color::Blue,
|
||||
"magenta" => Color::Magenta,
|
||||
"cyan" => Color::Cyan,
|
||||
"gray" => Color::Gray,
|
||||
"grey" => Color::Gray,
|
||||
"darkgray" => Color::DarkGray,
|
||||
"lightred" => Color::LightRed,
|
||||
"lightgreen" => Color::LightGreen,
|
||||
"lightyellow" => Color::LightYellow,
|
||||
"lightblue" => Color::LightBlue,
|
||||
"lightmagenta" => Color::LightMagenta,
|
||||
"lightcyan" => Color::LightCyan,
|
||||
"white" => Color::White,
|
||||
};
|
||||
|
||||
pub fn convert_hex_to_color(hex: &str) -> error::Result<Color> {
|
||||
fn hex_err(hex: &str) -> error::Result<u8> {
|
||||
|
@ -149,14 +140,12 @@ pub fn get_style_from_rgb(rgb_str: &str) -> error::Result<Style> {
|
|||
}
|
||||
|
||||
fn convert_name_to_color(color_name: &str) -> error::Result<Color> {
|
||||
let color = COLOR_NAME_LOOKUP_TABLE.get(color_name.to_lowercase().as_str());
|
||||
if let Some(color) = color {
|
||||
return Ok(*color);
|
||||
}
|
||||
|
||||
Err(error::BottomError::ConfigError(format!(
|
||||
"\"{}\" is an invalid named colour.
|
||||
|
||||
if let Some(color) = COLOR_LOOKUP_TABLE.get(color_name.to_lowercase().as_str()) {
|
||||
Ok(*color)
|
||||
} else {
|
||||
Err(error::BottomError::ConfigError(format!(
|
||||
"\"{}\" is an invalid named colour.
|
||||
|
||||
The following are supported strings:
|
||||
+--------+------------+--------------+
|
||||
| Reset | Magenta | LightYellow |
|
||||
|
@ -172,8 +161,9 @@ The following are supported strings:
|
|||
| Blue | LightGreen | |
|
||||
+--------+------------+--------------+
|
||||
",
|
||||
color_name
|
||||
)))
|
||||
color_name
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_style_from_color_name(color_name: &str) -> error::Result<Style> {
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Painter {
|
|||
let title = if app_state.is_expanded {
|
||||
const TITLE_BASE: &str = " Battery ── Esc to go back ";
|
||||
Spans::from(vec![
|
||||
Span::styled(" Battery ".to_string(), self.colours.widget_title_style),
|
||||
Span::styled(" Battery ", self.colours.widget_title_style),
|
||||
Span::styled(
|
||||
format!(
|
||||
"─{}─ Esc to go back ",
|
||||
|
@ -49,10 +49,7 @@ impl Painter {
|
|||
),
|
||||
])
|
||||
} else {
|
||||
Spans::from(Span::styled(
|
||||
" Battery ".to_string(),
|
||||
self.colours.widget_title_style,
|
||||
))
|
||||
Spans::from(Span::styled(" Battery ", self.colours.widget_title_style))
|
||||
};
|
||||
|
||||
let battery_block = if draw_border {
|
||||
|
|
392
src/constants.rs
392
src/constants.rs
|
@ -29,235 +29,235 @@ pub static DEFAULT_HEADER_STYLE: Lazy<tui::style::Style> =
|
|||
|
||||
// Colour profiles
|
||||
pub static DEFAULT_LIGHT_MODE_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
|
||||
text_color: Some("black".to_string()),
|
||||
border_color: Some("black".to_string()),
|
||||
table_header_color: Some("black".to_string()),
|
||||
widget_title_color: Some("black".to_string()),
|
||||
selected_text_color: Some("white".to_string()),
|
||||
graph_color: Some("black".to_string()),
|
||||
disabled_text_color: Some("gray".to_string()),
|
||||
ram_color: Some("blue".to_string()),
|
||||
swap_color: Some("red".to_string()),
|
||||
arc_color: Some("LightBlue".to_string()),
|
||||
text_color: Some("black".into()),
|
||||
border_color: Some("black".into()),
|
||||
table_header_color: Some("black".into()),
|
||||
widget_title_color: Some("black".into()),
|
||||
selected_text_color: Some("white".into()),
|
||||
graph_color: Some("black".into()),
|
||||
disabled_text_color: Some("gray".into()),
|
||||
ram_color: Some("blue".into()),
|
||||
swap_color: Some("red".into()),
|
||||
arc_color: Some("LightBlue".into()),
|
||||
gpu_core_colors: Some(vec![
|
||||
"LightGreen".to_string(),
|
||||
"LightCyan".to_string(),
|
||||
"LightRed".to_string(),
|
||||
"Cyan".to_string(),
|
||||
"Green".to_string(),
|
||||
"Blue".to_string(),
|
||||
"Red".to_string(),
|
||||
"LightGreen".into(),
|
||||
"LightCyan".into(),
|
||||
"LightRed".into(),
|
||||
"Cyan".into(),
|
||||
"Green".into(),
|
||||
"Blue".into(),
|
||||
"Red".into(),
|
||||
]),
|
||||
rx_color: Some("blue".to_string()),
|
||||
tx_color: Some("red".to_string()),
|
||||
rx_total_color: Some("LightBlue".to_string()),
|
||||
tx_total_color: Some("LightRed".to_string()),
|
||||
rx_color: Some("blue".into()),
|
||||
tx_color: Some("red".into()),
|
||||
rx_total_color: Some("LightBlue".into()),
|
||||
tx_total_color: Some("LightRed".into()),
|
||||
cpu_core_colors: Some(vec![
|
||||
"LightMagenta".to_string(),
|
||||
"LightBlue".to_string(),
|
||||
"LightRed".to_string(),
|
||||
"Cyan".to_string(),
|
||||
"Green".to_string(),
|
||||
"Blue".to_string(),
|
||||
"Red".to_string(),
|
||||
"LightMagenta".into(),
|
||||
"LightBlue".into(),
|
||||
"LightRed".into(),
|
||||
"Cyan".into(),
|
||||
"Green".into(),
|
||||
"Blue".into(),
|
||||
"Red".into(),
|
||||
]),
|
||||
..ConfigColours::default()
|
||||
});
|
||||
|
||||
pub static GRUVBOX_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
|
||||
table_header_color: Some("#83a598".to_string()),
|
||||
all_cpu_color: Some("#8ec07c".to_string()),
|
||||
avg_cpu_color: Some("#fb4934".to_string()),
|
||||
table_header_color: Some("#83a598".into()),
|
||||
all_cpu_color: Some("#8ec07c".into()),
|
||||
avg_cpu_color: Some("#fb4934".into()),
|
||||
cpu_core_colors: Some(vec![
|
||||
"#cc241d".to_string(),
|
||||
"#98971a".to_string(),
|
||||
"#d79921".to_string(),
|
||||
"#458588".to_string(),
|
||||
"#b16286".to_string(),
|
||||
"#689d6a".to_string(),
|
||||
"#fe8019".to_string(),
|
||||
"#b8bb26".to_string(),
|
||||
"#fabd2f".to_string(),
|
||||
"#83a598".to_string(),
|
||||
"#d3869b".to_string(),
|
||||
"#d65d0e".to_string(),
|
||||
"#9d0006".to_string(),
|
||||
"#79740e".to_string(),
|
||||
"#b57614".to_string(),
|
||||
"#076678".to_string(),
|
||||
"#8f3f71".to_string(),
|
||||
"#427b58".to_string(),
|
||||
"#d65d03".to_string(),
|
||||
"#af3a03".to_string(),
|
||||
"#cc241d".into(),
|
||||
"#98971a".into(),
|
||||
"#d79921".into(),
|
||||
"#458588".into(),
|
||||
"#b16286".into(),
|
||||
"#689d6a".into(),
|
||||
"#fe8019".into(),
|
||||
"#b8bb26".into(),
|
||||
"#fabd2f".into(),
|
||||
"#83a598".into(),
|
||||
"#d3869b".into(),
|
||||
"#d65d0e".into(),
|
||||
"#9d0006".into(),
|
||||
"#79740e".into(),
|
||||
"#b57614".into(),
|
||||
"#076678".into(),
|
||||
"#8f3f71".into(),
|
||||
"#427b58".into(),
|
||||
"#d65d03".into(),
|
||||
"#af3a03".into(),
|
||||
]),
|
||||
ram_color: Some("#8ec07c".to_string()),
|
||||
swap_color: Some("#fabd2f".to_string()),
|
||||
arc_color: Some("#689d6a".to_string()),
|
||||
ram_color: Some("#8ec07c".into()),
|
||||
swap_color: Some("#fabd2f".into()),
|
||||
arc_color: Some("#689d6a".into()),
|
||||
gpu_core_colors: Some(vec![
|
||||
"#d79921".to_string(),
|
||||
"#458588".to_string(),
|
||||
"#b16286".to_string(),
|
||||
"#fe8019".to_string(),
|
||||
"#b8bb26".to_string(),
|
||||
"#cc241d".to_string(),
|
||||
"#98971a".to_string(),
|
||||
"#d79921".into(),
|
||||
"#458588".into(),
|
||||
"#b16286".into(),
|
||||
"#fe8019".into(),
|
||||
"#b8bb26".into(),
|
||||
"#cc241d".into(),
|
||||
"#98971a".into(),
|
||||
]),
|
||||
rx_color: Some("#8ec07c".to_string()),
|
||||
tx_color: Some("#fabd2f".to_string()),
|
||||
rx_total_color: Some("#689d6a".to_string()),
|
||||
tx_total_color: Some("#d79921".to_string()),
|
||||
border_color: Some("#ebdbb2".to_string()),
|
||||
highlighted_border_color: Some("#fe8019".to_string()),
|
||||
disabled_text_color: Some("#665c54".to_string()),
|
||||
text_color: Some("#ebdbb2".to_string()),
|
||||
selected_text_color: Some("#1d2021".to_string()),
|
||||
selected_bg_color: Some("#ebdbb2".to_string()),
|
||||
widget_title_color: Some("#ebdbb2".to_string()),
|
||||
graph_color: Some("#ebdbb2".to_string()),
|
||||
high_battery_color: Some("#98971a".to_string()),
|
||||
medium_battery_color: Some("#fabd2f".to_string()),
|
||||
low_battery_color: Some("#fb4934".to_string()),
|
||||
rx_color: Some("#8ec07c".into()),
|
||||
tx_color: Some("#fabd2f".into()),
|
||||
rx_total_color: Some("#689d6a".into()),
|
||||
tx_total_color: Some("#d79921".into()),
|
||||
border_color: Some("#ebdbb2".into()),
|
||||
highlighted_border_color: Some("#fe8019".into()),
|
||||
disabled_text_color: Some("#665c54".into()),
|
||||
text_color: Some("#ebdbb2".into()),
|
||||
selected_text_color: Some("#1d2021".into()),
|
||||
selected_bg_color: Some("#ebdbb2".into()),
|
||||
widget_title_color: Some("#ebdbb2".into()),
|
||||
graph_color: Some("#ebdbb2".into()),
|
||||
high_battery_color: Some("#98971a".into()),
|
||||
medium_battery_color: Some("#fabd2f".into()),
|
||||
low_battery_color: Some("#fb4934".into()),
|
||||
});
|
||||
|
||||
pub static GRUVBOX_LIGHT_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
|
||||
table_header_color: Some("#076678".to_string()),
|
||||
all_cpu_color: Some("#8ec07c".to_string()),
|
||||
avg_cpu_color: Some("#fb4934".to_string()),
|
||||
table_header_color: Some("#076678".into()),
|
||||
all_cpu_color: Some("#8ec07c".into()),
|
||||
avg_cpu_color: Some("#fb4934".into()),
|
||||
cpu_core_colors: Some(vec![
|
||||
"#cc241d".to_string(),
|
||||
"#98971a".to_string(),
|
||||
"#d79921".to_string(),
|
||||
"#458588".to_string(),
|
||||
"#b16286".to_string(),
|
||||
"#689d6a".to_string(),
|
||||
"#fe8019".to_string(),
|
||||
"#b8bb26".to_string(),
|
||||
"#fabd2f".to_string(),
|
||||
"#83a598".to_string(),
|
||||
"#d3869b".to_string(),
|
||||
"#d65d0e".to_string(),
|
||||
"#9d0006".to_string(),
|
||||
"#79740e".to_string(),
|
||||
"#b57614".to_string(),
|
||||
"#076678".to_string(),
|
||||
"#8f3f71".to_string(),
|
||||
"#427b58".to_string(),
|
||||
"#d65d03".to_string(),
|
||||
"#af3a03".to_string(),
|
||||
"#cc241d".into(),
|
||||
"#98971a".into(),
|
||||
"#d79921".into(),
|
||||
"#458588".into(),
|
||||
"#b16286".into(),
|
||||
"#689d6a".into(),
|
||||
"#fe8019".into(),
|
||||
"#b8bb26".into(),
|
||||
"#fabd2f".into(),
|
||||
"#83a598".into(),
|
||||
"#d3869b".into(),
|
||||
"#d65d0e".into(),
|
||||
"#9d0006".into(),
|
||||
"#79740e".into(),
|
||||
"#b57614".into(),
|
||||
"#076678".into(),
|
||||
"#8f3f71".into(),
|
||||
"#427b58".into(),
|
||||
"#d65d03".into(),
|
||||
"#af3a03".into(),
|
||||
]),
|
||||
ram_color: Some("#427b58".to_string()),
|
||||
swap_color: Some("#cc241d".to_string()),
|
||||
arc_color: Some("#689d6a".to_string()),
|
||||
ram_color: Some("#427b58".into()),
|
||||
swap_color: Some("#cc241d".into()),
|
||||
arc_color: Some("#689d6a".into()),
|
||||
gpu_core_colors: Some(vec![
|
||||
"#9d0006".to_string(),
|
||||
"#98971a".to_string(),
|
||||
"#d79921".to_string(),
|
||||
"#458588".to_string(),
|
||||
"#b16286".to_string(),
|
||||
"#fe8019".to_string(),
|
||||
"#b8bb26".to_string(),
|
||||
"#9d0006".into(),
|
||||
"#98971a".into(),
|
||||
"#d79921".into(),
|
||||
"#458588".into(),
|
||||
"#b16286".into(),
|
||||
"#fe8019".into(),
|
||||
"#b8bb26".into(),
|
||||
]),
|
||||
rx_color: Some("#427b58".to_string()),
|
||||
tx_color: Some("#cc241d".to_string()),
|
||||
rx_total_color: Some("#689d6a".to_string()),
|
||||
tx_total_color: Some("#9d0006".to_string()),
|
||||
border_color: Some("#3c3836".to_string()),
|
||||
highlighted_border_color: Some("#af3a03".to_string()),
|
||||
disabled_text_color: Some("#d5c4a1".to_string()),
|
||||
text_color: Some("#3c3836".to_string()),
|
||||
selected_text_color: Some("#ebdbb2".to_string()),
|
||||
selected_bg_color: Some("#3c3836".to_string()),
|
||||
widget_title_color: Some("#3c3836".to_string()),
|
||||
graph_color: Some("#3c3836".to_string()),
|
||||
high_battery_color: Some("#98971a".to_string()),
|
||||
medium_battery_color: Some("#d79921".to_string()),
|
||||
low_battery_color: Some("#cc241d".to_string()),
|
||||
rx_color: Some("#427b58".into()),
|
||||
tx_color: Some("#cc241d".into()),
|
||||
rx_total_color: Some("#689d6a".into()),
|
||||
tx_total_color: Some("#9d0006".into()),
|
||||
border_color: Some("#3c3836".into()),
|
||||
highlighted_border_color: Some("#af3a03".into()),
|
||||
disabled_text_color: Some("#d5c4a1".into()),
|
||||
text_color: Some("#3c3836".into()),
|
||||
selected_text_color: Some("#ebdbb2".into()),
|
||||
selected_bg_color: Some("#3c3836".into()),
|
||||
widget_title_color: Some("#3c3836".into()),
|
||||
graph_color: Some("#3c3836".into()),
|
||||
high_battery_color: Some("#98971a".into()),
|
||||
medium_battery_color: Some("#d79921".into()),
|
||||
low_battery_color: Some("#cc241d".into()),
|
||||
});
|
||||
|
||||
pub static NORD_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
|
||||
table_header_color: Some("#81a1c1".to_string()),
|
||||
all_cpu_color: Some("#88c0d0".to_string()),
|
||||
avg_cpu_color: Some("#8fbcbb".to_string()),
|
||||
table_header_color: Some("#81a1c1".into()),
|
||||
all_cpu_color: Some("#88c0d0".into()),
|
||||
avg_cpu_color: Some("#8fbcbb".into()),
|
||||
cpu_core_colors: Some(vec![
|
||||
"#5e81ac".to_string(),
|
||||
"#81a1c1".to_string(),
|
||||
"#d8dee9".to_string(),
|
||||
"#b48ead".to_string(),
|
||||
"#a3be8c".to_string(),
|
||||
"#ebcb8b".to_string(),
|
||||
"#d08770".to_string(),
|
||||
"#bf616a".to_string(),
|
||||
"#5e81ac".into(),
|
||||
"#81a1c1".into(),
|
||||
"#d8dee9".into(),
|
||||
"#b48ead".into(),
|
||||
"#a3be8c".into(),
|
||||
"#ebcb8b".into(),
|
||||
"#d08770".into(),
|
||||
"#bf616a".into(),
|
||||
]),
|
||||
ram_color: Some("#88c0d0".to_string()),
|
||||
swap_color: Some("#d08770".to_string()),
|
||||
arc_color: Some("#5e81ac".to_string()),
|
||||
ram_color: Some("#88c0d0".into()),
|
||||
swap_color: Some("#d08770".into()),
|
||||
arc_color: Some("#5e81ac".into()),
|
||||
gpu_core_colors: Some(vec![
|
||||
"#8fbcbb".to_string(),
|
||||
"#81a1c1".to_string(),
|
||||
"#d8dee9".to_string(),
|
||||
"#b48ead".to_string(),
|
||||
"#a3be8c".to_string(),
|
||||
"#ebcb8b".to_string(),
|
||||
"#bf616a".to_string(),
|
||||
"#8fbcbb".into(),
|
||||
"#81a1c1".into(),
|
||||
"#d8dee9".into(),
|
||||
"#b48ead".into(),
|
||||
"#a3be8c".into(),
|
||||
"#ebcb8b".into(),
|
||||
"#bf616a".into(),
|
||||
]),
|
||||
rx_color: Some("#88c0d0".to_string()),
|
||||
tx_color: Some("#d08770".to_string()),
|
||||
rx_total_color: Some("#5e81ac".to_string()),
|
||||
tx_total_color: Some("#8fbcbb".to_string()),
|
||||
border_color: Some("#88c0d0".to_string()),
|
||||
highlighted_border_color: Some("#5e81ac".to_string()),
|
||||
disabled_text_color: Some("#4c566a".to_string()),
|
||||
text_color: Some("#e5e9f0".to_string()),
|
||||
selected_text_color: Some("#2e3440".to_string()),
|
||||
selected_bg_color: Some("#88c0d0".to_string()),
|
||||
widget_title_color: Some("#e5e9f0".to_string()),
|
||||
graph_color: Some("#e5e9f0".to_string()),
|
||||
high_battery_color: Some("#a3be8c".to_string()),
|
||||
medium_battery_color: Some("#ebcb8b".to_string()),
|
||||
low_battery_color: Some("#bf616a".to_string()),
|
||||
rx_color: Some("#88c0d0".into()),
|
||||
tx_color: Some("#d08770".into()),
|
||||
rx_total_color: Some("#5e81ac".into()),
|
||||
tx_total_color: Some("#8fbcbb".into()),
|
||||
border_color: Some("#88c0d0".into()),
|
||||
highlighted_border_color: Some("#5e81ac".into()),
|
||||
disabled_text_color: Some("#4c566a".into()),
|
||||
text_color: Some("#e5e9f0".into()),
|
||||
selected_text_color: Some("#2e3440".into()),
|
||||
selected_bg_color: Some("#88c0d0".into()),
|
||||
widget_title_color: Some("#e5e9f0".into()),
|
||||
graph_color: Some("#e5e9f0".into()),
|
||||
high_battery_color: Some("#a3be8c".into()),
|
||||
medium_battery_color: Some("#ebcb8b".into()),
|
||||
low_battery_color: Some("#bf616a".into()),
|
||||
});
|
||||
|
||||
pub static NORD_LIGHT_COLOUR_PALETTE: Lazy<ConfigColours> = Lazy::new(|| ConfigColours {
|
||||
table_header_color: Some("#5e81ac".to_string()),
|
||||
all_cpu_color: Some("#81a1c1".to_string()),
|
||||
avg_cpu_color: Some("#8fbcbb".to_string()),
|
||||
table_header_color: Some("#5e81ac".into()),
|
||||
all_cpu_color: Some("#81a1c1".into()),
|
||||
avg_cpu_color: Some("#8fbcbb".into()),
|
||||
cpu_core_colors: Some(vec![
|
||||
"#5e81ac".to_string(),
|
||||
"#88c0d0".to_string(),
|
||||
"#4c566a".to_string(),
|
||||
"#b48ead".to_string(),
|
||||
"#a3be8c".to_string(),
|
||||
"#ebcb8b".to_string(),
|
||||
"#d08770".to_string(),
|
||||
"#bf616a".to_string(),
|
||||
"#5e81ac".into(),
|
||||
"#88c0d0".into(),
|
||||
"#4c566a".into(),
|
||||
"#b48ead".into(),
|
||||
"#a3be8c".into(),
|
||||
"#ebcb8b".into(),
|
||||
"#d08770".into(),
|
||||
"#bf616a".into(),
|
||||
]),
|
||||
ram_color: Some("#81a1c1".to_string()),
|
||||
swap_color: Some("#d08770".to_string()),
|
||||
arc_color: Some("#5e81ac".to_string()),
|
||||
ram_color: Some("#81a1c1".into()),
|
||||
swap_color: Some("#d08770".into()),
|
||||
arc_color: Some("#5e81ac".into()),
|
||||
gpu_core_colors: Some(vec![
|
||||
"#8fbcbb".to_string(),
|
||||
"#88c0d0".to_string(),
|
||||
"#4c566a".to_string(),
|
||||
"#b48ead".to_string(),
|
||||
"#a3be8c".to_string(),
|
||||
"#ebcb8b".to_string(),
|
||||
"#bf616a".to_string(),
|
||||
"#8fbcbb".into(),
|
||||
"#88c0d0".into(),
|
||||
"#4c566a".into(),
|
||||
"#b48ead".into(),
|
||||
"#a3be8c".into(),
|
||||
"#ebcb8b".into(),
|
||||
"#bf616a".into(),
|
||||
]),
|
||||
rx_color: Some("#81a1c1".to_string()),
|
||||
tx_color: Some("#d08770".to_string()),
|
||||
rx_total_color: Some("#5e81ac".to_string()),
|
||||
tx_total_color: Some("#8fbcbb".to_string()),
|
||||
border_color: Some("#2e3440".to_string()),
|
||||
highlighted_border_color: Some("#5e81ac".to_string()),
|
||||
disabled_text_color: Some("#d8dee9".to_string()),
|
||||
text_color: Some("#2e3440".to_string()),
|
||||
selected_text_color: Some("#f5f5f5".to_string()),
|
||||
selected_bg_color: Some("#5e81ac".to_string()),
|
||||
widget_title_color: Some("#2e3440".to_string()),
|
||||
graph_color: Some("#2e3440".to_string()),
|
||||
high_battery_color: Some("#a3be8c".to_string()),
|
||||
medium_battery_color: Some("#ebcb8b".to_string()),
|
||||
low_battery_color: Some("#bf616a".to_string()),
|
||||
rx_color: Some("#81a1c1".into()),
|
||||
tx_color: Some("#d08770".into()),
|
||||
rx_total_color: Some("#5e81ac".into()),
|
||||
tx_total_color: Some("#8fbcbb".into()),
|
||||
border_color: Some("#2e3440".into()),
|
||||
highlighted_border_color: Some("#5e81ac".into()),
|
||||
disabled_text_color: Some("#d8dee9".into()),
|
||||
text_color: Some("#2e3440".into()),
|
||||
selected_text_color: Some("#f5f5f5".into()),
|
||||
selected_bg_color: Some("#5e81ac".into()),
|
||||
widget_title_color: Some("#2e3440".into()),
|
||||
graph_color: Some("#2e3440".into()),
|
||||
high_battery_color: Some("#a3be8c".into()),
|
||||
medium_battery_color: Some("#ebcb8b".into()),
|
||||
low_battery_color: Some("#bf616a".into()),
|
||||
});
|
||||
|
||||
// Help text
|
||||
|
|
|
@ -371,7 +371,7 @@ pub fn convert_network_data_points(
|
|||
),
|
||||
};
|
||||
|
||||
let (rx_converted_result, total_rx_converted_result): ((f64, String), (f64, String)) =
|
||||
let (rx_converted_result, total_rx_converted_result): ((f64, String), (f64, &'static str)) =
|
||||
if network_use_binary_prefix {
|
||||
(
|
||||
get_binary_prefix(rx_data, unit), // If this isn't obvious why there's two functions, one you can configure the unit, the other is always bytes
|
||||
|
@ -384,7 +384,7 @@ pub fn convert_network_data_points(
|
|||
)
|
||||
};
|
||||
|
||||
let (tx_converted_result, total_tx_converted_result): ((f64, String), (f64, String)) =
|
||||
let (tx_converted_result, total_tx_converted_result): ((f64, String), (f64, &'static str)) =
|
||||
if network_use_binary_prefix {
|
||||
(
|
||||
get_binary_prefix(tx_data, unit),
|
||||
|
|
|
@ -114,29 +114,29 @@ impl WidgetIdEnabled {
|
|||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct ConfigColours {
|
||||
pub table_header_color: Option<String>,
|
||||
pub all_cpu_color: Option<String>,
|
||||
pub avg_cpu_color: Option<String>,
|
||||
pub cpu_core_colors: Option<Vec<String>>,
|
||||
pub ram_color: Option<String>,
|
||||
pub swap_color: Option<String>,
|
||||
pub arc_color: Option<String>,
|
||||
pub gpu_core_colors: Option<Vec<String>>,
|
||||
pub rx_color: Option<String>,
|
||||
pub tx_color: Option<String>,
|
||||
pub rx_total_color: Option<String>, // These only affect basic mode.
|
||||
pub tx_total_color: Option<String>, // These only affect basic mode.
|
||||
pub border_color: Option<String>,
|
||||
pub highlighted_border_color: Option<String>,
|
||||
pub disabled_text_color: Option<String>,
|
||||
pub text_color: Option<String>,
|
||||
pub selected_text_color: Option<String>,
|
||||
pub selected_bg_color: Option<String>,
|
||||
pub widget_title_color: Option<String>,
|
||||
pub graph_color: Option<String>,
|
||||
pub high_battery_color: Option<String>,
|
||||
pub medium_battery_color: Option<String>,
|
||||
pub low_battery_color: Option<String>,
|
||||
pub table_header_color: Option<Cow<'static, str>>,
|
||||
pub all_cpu_color: Option<Cow<'static, str>>,
|
||||
pub avg_cpu_color: Option<Cow<'static, str>>,
|
||||
pub cpu_core_colors: Option<Vec<Cow<'static, str>>>,
|
||||
pub ram_color: Option<Cow<'static, str>>,
|
||||
pub swap_color: Option<Cow<'static, str>>,
|
||||
pub arc_color: Option<Cow<'static, str>>,
|
||||
pub gpu_core_colors: Option<Vec<Cow<'static, str>>>,
|
||||
pub rx_color: Option<Cow<'static, str>>,
|
||||
pub tx_color: Option<Cow<'static, str>>,
|
||||
pub rx_total_color: Option<Cow<'static, str>>, // These only affect basic mode.
|
||||
pub tx_total_color: Option<Cow<'static, str>>, // These only affect basic mode.
|
||||
pub border_color: Option<Cow<'static, str>>,
|
||||
pub highlighted_border_color: Option<Cow<'static, str>>,
|
||||
pub disabled_text_color: Option<Cow<'static, str>>,
|
||||
pub text_color: Option<Cow<'static, str>>,
|
||||
pub selected_text_color: Option<Cow<'static, str>>,
|
||||
pub selected_bg_color: Option<Cow<'static, str>>,
|
||||
pub widget_title_color: Option<Cow<'static, str>>,
|
||||
pub graph_color: Option<Cow<'static, str>>,
|
||||
pub high_battery_color: Option<Cow<'static, str>>,
|
||||
pub medium_battery_color: Option<Cow<'static, str>>,
|
||||
pub low_battery_color: Option<Cow<'static, str>>,
|
||||
}
|
||||
|
||||
impl ConfigColours {
|
||||
|
|
|
@ -100,13 +100,7 @@ impl From<regex::Error> for BottomError {
|
|||
let err_str = err.to_string();
|
||||
let error = err_str.split('\n').map(|s| s.trim()).collect::<Vec<_>>();
|
||||
|
||||
BottomError::QueryError(
|
||||
format!(
|
||||
"Regex error: {}",
|
||||
error.last().unwrap_or(&"".to_string().as_str())
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
BottomError::QueryError(format!("Regex error: {}", error.last().unwrap_or(&"")).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,26 +47,26 @@ pub const LOG_TEBI_LIMIT_U32: u32 = 40;
|
|||
/// Returns a tuple containing the value and the unit in bytes. In units of 1024.
|
||||
/// This only supports up to a tebi. Note the "single" unit will have a space appended to match the others if
|
||||
/// `spacing` is true.
|
||||
pub fn get_binary_bytes(bytes: u64) -> (f64, String) {
|
||||
pub fn get_binary_bytes(bytes: u64) -> (f64, &'static str) {
|
||||
match bytes {
|
||||
b if b < KIBI_LIMIT => (bytes as f64, "B".to_string()),
|
||||
b if b < MEBI_LIMIT => (bytes as f64 / 1024.0, "KiB".to_string()),
|
||||
b if b < GIBI_LIMIT => (bytes as f64 / 1_048_576.0, "MiB".to_string()),
|
||||
b if b < TERA_LIMIT => (bytes as f64 / 1_073_741_824.0, "GiB".to_string()),
|
||||
_ => (bytes as f64 / 1_099_511_627_776.0, "TiB".to_string()),
|
||||
b if b < KIBI_LIMIT => (bytes as f64, "B"),
|
||||
b if b < MEBI_LIMIT => (bytes as f64 / 1024.0, "KiB"),
|
||||
b if b < GIBI_LIMIT => (bytes as f64 / 1_048_576.0, "MiB"),
|
||||
b if b < TERA_LIMIT => (bytes as f64 / 1_073_741_824.0, "GiB"),
|
||||
_ => (bytes as f64 / 1_099_511_627_776.0, "TiB"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a tuple containing the value and the unit in bytes. In units of 1000.
|
||||
/// This only supports up to a tera. Note the "single" unit will have a space appended to match the others if
|
||||
/// `spacing` is true.
|
||||
pub fn get_decimal_bytes(bytes: u64) -> (f64, String) {
|
||||
pub fn get_decimal_bytes(bytes: u64) -> (f64, &'static str) {
|
||||
match bytes {
|
||||
b if b < KILO_LIMIT => (bytes as f64, "B".to_string()),
|
||||
b if b < MEGA_LIMIT => (bytes as f64 / 1000.0, "KB".to_string()),
|
||||
b if b < GIGA_LIMIT => (bytes as f64 / 1_000_000.0, "MB".to_string()),
|
||||
b if b < TERA_LIMIT => (bytes as f64 / 1_000_000_000.0, "GB".to_string()),
|
||||
_ => (bytes as f64 / 1_000_000_000_000.0, "TB".to_string()),
|
||||
b if b < KILO_LIMIT => (bytes as f64, "B"),
|
||||
b if b < MEGA_LIMIT => (bytes as f64 / 1000.0, "KB"),
|
||||
b if b < GIGA_LIMIT => (bytes as f64 / 1_000_000.0, "MB"),
|
||||
b if b < TERA_LIMIT => (bytes as f64 / 1_000_000_000.0, "GB"),
|
||||
_ => (bytes as f64 / 1_000_000_000_000.0, "TB"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue