mirror of
https://github.com/orhun/kmon
synced 2024-07-08 20:06:03 +00:00
Add accent-color option
Allows to pick default text color
This commit is contained in:
parent
e8196c90b4
commit
60cc86a0c7
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.4.0] - 2020-07-31
|
||||
### Changed
|
||||
- Add accent color option to set default text color
|
||||
|
||||
## [1.3.5] - 2020-07-30
|
||||
### Changed
|
||||
- Update README.md about Arch Linux packages
|
||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -137,7 +137,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "kmon"
|
||||
version = "1.3.5"
|
||||
version = "1.4.0"
|
||||
dependencies = [
|
||||
"bytesize 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "kmon"
|
||||
version = "1.3.5"
|
||||
version = "1.4.0"
|
||||
description = "Linux kernel manager and activity monitor"
|
||||
authors = ["orhun <orhunparmaksiz@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -217,8 +217,9 @@ kmon [FLAGS] [OPTIONS] [SUBCOMMANDS]
|
|||
### Options
|
||||
|
||||
```
|
||||
-c, --color <COLOR> Set the main color using hex or color name [default: darkgray]
|
||||
-t, --tickrate <MS> Set the refresh rate of the terminal [default: 250]
|
||||
-a, --accent-color <COLOR> Set the accent color using hex or color name [default: gray]
|
||||
-c, --color <COLOR> Set the main color using hex or color name [default: darkgray]
|
||||
-t, --tickrate <MS> Set the refresh rate of the terminal [default: 250]
|
||||
```
|
||||
|
||||
### Subcommands
|
||||
|
|
16
src/style.rs
16
src/style.rs
|
@ -106,6 +106,20 @@ impl Style {
|
|||
"lightcyan" => Color::LightCyan,
|
||||
"white" => Color::White
|
||||
];
|
||||
let accent_color = match args.value_of("accent-color") {
|
||||
Some(v) => *colors.get::<str>(&v.to_lowercase()).unwrap_or({
|
||||
if let Ok(rgb) = Rgb::from_hex_str(&format!("#{}", v)) {
|
||||
Box::leak(Box::new(Color::Rgb(
|
||||
rgb.get_red() as u8,
|
||||
rgb.get_green() as u8,
|
||||
rgb.get_blue() as u8,
|
||||
)))
|
||||
} else {
|
||||
&Color::White
|
||||
}
|
||||
}),
|
||||
None => Color::White,
|
||||
};
|
||||
let main_color = match args.value_of("color") {
|
||||
Some(v) => *colors.get::<str>(&v.to_lowercase()).unwrap_or({
|
||||
if let Ok(rgb) = Rgb::from_hex_str(&format!("#{}", v)) {
|
||||
|
@ -121,7 +135,7 @@ impl Style {
|
|||
None => Color::DarkGray,
|
||||
};
|
||||
Self {
|
||||
default: TuiStyle::default(),
|
||||
default: TuiStyle::default().fg(accent_color),
|
||||
bold: TuiStyle::default().modifier(Modifier::BOLD),
|
||||
colored: TuiStyle::default().fg(main_color),
|
||||
unicode: Unicode::new(!args.is_present("unicode")),
|
||||
|
|
|
@ -60,6 +60,15 @@ pub fn parse_args() -> clap::ArgMatches<'static> {
|
|||
))
|
||||
.usage("kmon [FLAGS] [OPTIONS] [SUBCOMMANDS]")
|
||||
.before_help(ASCII_LOGO)
|
||||
.arg(
|
||||
Arg::with_name("accent-color")
|
||||
.short("a")
|
||||
.long("accent-color")
|
||||
.value_name("COLOR")
|
||||
.default_value("white")
|
||||
.help("Set the accent color using hex or color name")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("color")
|
||||
.short("c")
|
||||
|
|
Loading…
Reference in New Issue
Block a user