-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loadavg): add module for load average
Inspired by #1252 (comment) Example configuration: [loadavg] disabled = false [[loadavg.display]] threshold_one = 8.0 style = "bold red" [[loadavg.display]] threshold_one = 4.0 style = "bold yellow" [[loadavg.display]] threshold_one = 2.0 style = "bold white" [[loadavg.display]] threshold_one = 0.0 style = "dimmed white"
- Loading branch information
Showing
8 changed files
with
393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Deserialize, Serialize)] | ||
#[cfg_attr( | ||
feature = "config-schema", | ||
derive(schemars::JsonSchema), | ||
schemars(deny_unknown_fields) | ||
)] | ||
#[serde(default)] | ||
pub struct LoadavgConfig<'a> { | ||
pub format: &'a str, | ||
pub symbol: &'a str, | ||
#[serde(borrow)] | ||
pub display: Vec<LoadavgDisplayConfig<'a>>, | ||
pub disabled: bool, | ||
} | ||
|
||
impl<'a> Default for LoadavgConfig<'a> { | ||
fn default() -> Self { | ||
LoadavgConfig { | ||
format: "[$symbol $one $five $fifteen]($style) ", | ||
symbol: "⌛", | ||
display: vec![LoadavgDisplayConfig::default()], | ||
disabled: true, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Deserialize, Serialize)] | ||
#[cfg_attr( | ||
feature = "config-schema", | ||
derive(schemars::JsonSchema), | ||
schemars(deny_unknown_fields) | ||
)] | ||
#[serde(default)] | ||
pub struct LoadavgDisplayConfig<'a> { | ||
pub threshold_one: f32, | ||
pub threshold_five: f32, | ||
pub threshold_fifteen: f32, | ||
pub style: &'a str, | ||
pub symbol: Option<&'a str>, | ||
} | ||
|
||
impl<'a> Default for LoadavgDisplayConfig<'a> { | ||
fn default() -> Self { | ||
LoadavgDisplayConfig { | ||
threshold_one: f32::NAN, | ||
threshold_five: f32::NAN, | ||
threshold_fifteen: f32::NAN, | ||
style: "white bold", | ||
symbol: None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.