Version 0.1.10, fix clippy warnings
This commit is contained in:
parent
4584dd018d
commit
5b2c495982
5 changed files with 24 additions and 19 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -141,7 +141,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swaybar_info"
|
name = "swaybar_info"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "swaybar_info"
|
name = "swaybar_info"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Provides swaybar with info to be displayed"
|
description = "Provides swaybar with info to be displayed"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
## Upcoming Changes
|
## Upcoming Changes
|
||||||
|
|
||||||
|
## 0.1.10
|
||||||
|
|
||||||
|
Colorize the netgraph based on if download or upload is greater.
|
||||||
|
Download is red, upload is green, and same amount is yellow.
|
||||||
|
|
||||||
## 0.1.9
|
## 0.1.9
|
||||||
|
|
||||||
Impl. changing the size of the net-graph (default 10).
|
Impl. changing the size of the net-graph (default 10).
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -288,32 +288,32 @@ fn main() {
|
||||||
if (net_graph_max.is_some() || net_graph_is_dynamic) && !graph_items.is_empty()
|
if (net_graph_max.is_some() || net_graph_is_dynamic) && !graph_items.is_empty()
|
||||||
{
|
{
|
||||||
match graph_items[max_idx].get_value_type() {
|
match graph_items[max_idx].get_value_type() {
|
||||||
proc::GraphItemType::DOWNLOAD => {
|
proc::GraphItemType::Download => {
|
||||||
graph_obj.color = Some("#ff8888ff".into())
|
graph_obj.color = Some("#ff8888ff".into())
|
||||||
}
|
}
|
||||||
proc::GraphItemType::UPLOAD => {
|
proc::GraphItemType::Upload => {
|
||||||
graph_obj.color = Some("#88ff88ff".into())
|
graph_obj.color = Some("#88ff88ff".into())
|
||||||
}
|
}
|
||||||
proc::GraphItemType::BOTH => graph_obj.color = Some("#ffff88ff".into()),
|
proc::GraphItemType::Both => graph_obj.color = Some("#ffff88ff".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if net_graph_max.is_some() || net_graph_is_dynamic {
|
if net_graph_max.is_some() || net_graph_is_dynamic {
|
||||||
for i in 0..net_graph_size.unwrap() {
|
for (idx, item) in graph_items.iter().enumerate() {
|
||||||
let name = "net_graph".to_owned() + &i.to_string();
|
let name = "net_graph".to_owned() + &idx.to_string();
|
||||||
if let Some(graph_obj) = array.get_by_name_mut(&name) {
|
if let Some(graph_obj) = array.get_by_name_mut(&name) {
|
||||||
match graph_items[i].get_value_type() {
|
match item.get_value_type() {
|
||||||
proc::GraphItemType::DOWNLOAD => {
|
proc::GraphItemType::Download => {
|
||||||
graph_obj.color = Some("#ff8888ff".into())
|
graph_obj.color = Some("#ff8888ff".into())
|
||||||
}
|
}
|
||||||
proc::GraphItemType::UPLOAD => {
|
proc::GraphItemType::Upload => {
|
||||||
graph_obj.color = Some("#88ff88ff".into())
|
graph_obj.color = Some("#88ff88ff".into())
|
||||||
}
|
}
|
||||||
proc::GraphItemType::BOTH => graph_obj.color = Some("#ffff88ff".into()),
|
proc::GraphItemType::Both => graph_obj.color = Some("#ffff88ff".into()),
|
||||||
}
|
}
|
||||||
graph_obj.full_text = graph_items[i].get_value().into();
|
graph_obj.full_text = item.get_value().into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/proc.rs
14
src/proc.rs
|
@ -59,9 +59,9 @@ impl std::error::Error for Error {
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum GraphItemType {
|
pub enum GraphItemType {
|
||||||
DOWNLOAD,
|
Download,
|
||||||
UPLOAD,
|
Upload,
|
||||||
BOTH,
|
Both,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
|
@ -106,7 +106,7 @@ impl NetInfo {
|
||||||
graph: vec![GraphItem {
|
graph: vec![GraphItem {
|
||||||
value: ' ',
|
value: ' ',
|
||||||
num_value: 0.0,
|
num_value: 0.0,
|
||||||
value_type: GraphItemType::BOTH,
|
value_type: GraphItemType::Both,
|
||||||
}],
|
}],
|
||||||
down: 0,
|
down: 0,
|
||||||
prev_down: 0,
|
prev_down: 0,
|
||||||
|
@ -213,13 +213,13 @@ impl NetInfo {
|
||||||
write!(&mut output, "{:.0} B", up_diff)?;
|
write!(&mut output, "{:.0} B", up_diff)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut graph_type = GraphItemType::BOTH;
|
let mut graph_type = GraphItemType::Both;
|
||||||
let diff_max = if down_diff > up_diff {
|
let diff_max = if down_diff > up_diff {
|
||||||
graph_type = GraphItemType::DOWNLOAD;
|
graph_type = GraphItemType::Download;
|
||||||
down_diff
|
down_diff
|
||||||
} else {
|
} else {
|
||||||
if down_diff < up_diff {
|
if down_diff < up_diff {
|
||||||
graph_type = GraphItemType::UPLOAD;
|
graph_type = GraphItemType::Upload;
|
||||||
}
|
}
|
||||||
up_diff
|
up_diff
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue