]> git.seodisparate.com - swaybar_info/commitdiff
Version 0.1.10, fix clippy warnings 0.1.10
authorStephen Seo <seo.disparate@gmail.com>
Sun, 21 May 2023 05:30:38 +0000 (14:30 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sun, 21 May 2023 05:30:38 +0000 (14:30 +0900)
Cargo.lock
Cargo.toml
Changelog.md
src/main.rs
src/proc.rs

index 33555d2e755e3e0aec3470fb17045ab436f95a30..6ed2418f8c0b11319538c3ca393156a970f6bf3e 100644 (file)
@@ -141,7 +141,7 @@ dependencies = [
 
 [[package]]
 name = "swaybar_info"
-version = "0.1.9"
+version = "0.1.10"
 dependencies = [
  "chrono",
  "regex",
index 51f57d077599b687054e20a0b0deb21d28d30fb5..75935d48f3fdf1d8ed32be15797be92413d50af4 100644 (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"
index 4cb357767d6ba6f5e190ff98146524ae64024da4..ea056b60bf5a4f63a1fa65143eb6a1896c42155f 100644 (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).
index 0fe955c10e26770b9308ab7f7991becb1010a666..b706566403148b7740e1a41f4e624f3b8c19b109 100644 (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();
                     }
                 }
             }
index a174e89456c2696f3a575fe17d0084e720314339..1baaeac2fc4d37e5cf56e92c8f67b74f65a3ad8b 100644 (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
         };