Version 0.1.10, fix clippy warnings

This commit is contained in:
Stephen Seo 2023-05-21 14:30:38 +09:00
parent 4584dd018d
commit 5b2c495982
5 changed files with 24 additions and 19 deletions

2
Cargo.lock generated
View file

@ -141,7 +141,7 @@ dependencies = [
[[package]]
name = "swaybar_info"
version = "0.1.9"
version = "0.1.10"
dependencies = [
"chrono",
"regex",

View file

@ -1,6 +1,6 @@
[package]
name = "swaybar_info"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
description = "Provides swaybar with info to be displayed"
license = "MIT"

View file

@ -2,6 +2,11 @@
## 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
Impl. changing the size of the net-graph (default 10).

View file

@ -288,32 +288,32 @@ fn main() {
if (net_graph_max.is_some() || net_graph_is_dynamic) && !graph_items.is_empty()
{
match graph_items[max_idx].get_value_type() {
proc::GraphItemType::DOWNLOAD => {
proc::GraphItemType::Download => {
graph_obj.color = Some("#ff8888ff".into())
}
proc::GraphItemType::UPLOAD => {
proc::GraphItemType::Upload => {
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 {
for i in 0..net_graph_size.unwrap() {
let name = "net_graph".to_owned() + &i.to_string();
for (idx, item) in graph_items.iter().enumerate() {
let name = "net_graph".to_owned() + &idx.to_string();
if let Some(graph_obj) = array.get_by_name_mut(&name) {
match graph_items[i].get_value_type() {
proc::GraphItemType::DOWNLOAD => {
match item.get_value_type() {
proc::GraphItemType::Download => {
graph_obj.color = Some("#ff8888ff".into())
}
proc::GraphItemType::UPLOAD => {
proc::GraphItemType::Upload => {
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();
}
}
}

View file

@ -59,9 +59,9 @@ impl std::error::Error for Error {
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum GraphItemType {
DOWNLOAD,
UPLOAD,
BOTH,
Download,
Upload,
Both,
}
#[derive(Debug, Copy, Clone, PartialEq)]
@ -106,7 +106,7 @@ impl NetInfo {
graph: vec![GraphItem {
value: ' ',
num_value: 0.0,
value_type: GraphItemType::BOTH,
value_type: GraphItemType::Both,
}],
down: 0,
prev_down: 0,
@ -213,13 +213,13 @@ impl NetInfo {
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 {
graph_type = GraphItemType::DOWNLOAD;
graph_type = GraphItemType::Download;
down_diff
} else {
if down_diff < up_diff {
graph_type = GraphItemType::UPLOAD;
graph_type = GraphItemType::Upload;
}
up_diff
};