Version 0.1.11, cleanup colorizing net graph
This commit is contained in:
parent
5b2c495982
commit
c12dafab07
4 changed files with 27 additions and 34 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.10"
|
version = "0.1.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "swaybar_info"
|
name = "swaybar_info"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
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,10 @@
|
||||||
|
|
||||||
## Upcoming Changes
|
## Upcoming Changes
|
||||||
|
|
||||||
|
## 0.1.11
|
||||||
|
|
||||||
|
Use pango markup to colorize the netgraph, making it look cleaner.
|
||||||
|
|
||||||
## 0.1.10
|
## 0.1.10
|
||||||
|
|
||||||
Colorize the netgraph based on if download or upload is greater.
|
Colorize the netgraph based on if download or upload is greater.
|
||||||
|
|
47
src/main.rs
47
src/main.rs
|
@ -224,32 +224,13 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
|
||||||
let mut graph_obj = SwaybarObject::from_string(
|
let mut graph_obj = SwaybarObject::from_string(
|
||||||
"net_graph".to_owned() + &i.to_string(),
|
"net_graph".to_owned(),
|
||||||
" ".to_owned(),
|
" ".to_owned().repeat(net_graph_size.unwrap()),
|
||||||
);
|
);
|
||||||
if i == 0 {
|
graph_obj.markup = Some("pango".to_owned());
|
||||||
graph_obj.border_left = Some(1);
|
|
||||||
} else {
|
|
||||||
graph_obj.border_left = Some(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if i == net_graph_size.unwrap() - 1 {
|
|
||||||
graph_obj.border_right = Some(1);
|
|
||||||
graph_obj.separator_block_width = Some(12);
|
|
||||||
} else {
|
|
||||||
graph_obj.border_right = Some(0);
|
|
||||||
graph_obj.separator_block_width = Some(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
graph_obj.border_top = Some(1);
|
|
||||||
graph_obj.border_bottom = Some(1);
|
|
||||||
graph_obj.color = Some("#ffff88".into());
|
|
||||||
graph_obj.separator = Some(false);
|
|
||||||
array.push_object(graph_obj);
|
array.push_object(graph_obj);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut width_string: Option<String> = None;
|
let mut width_string: Option<String> = None;
|
||||||
if let Some(width) = net_width {
|
if let Some(width) = net_width {
|
||||||
|
@ -301,21 +282,29 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if net_graph_max.is_some() || net_graph_is_dynamic {
|
if net_graph_max.is_some() || net_graph_is_dynamic {
|
||||||
for (idx, item) in graph_items.iter().enumerate() {
|
if let Some(graph_obj) = array.get_by_name_mut("net_graph") {
|
||||||
let name = "net_graph".to_owned() + &idx.to_string();
|
let mut text = String::new();
|
||||||
if let Some(graph_obj) = array.get_by_name_mut(&name) {
|
for item in graph_items.iter() {
|
||||||
match item.get_value_type() {
|
match item.get_value_type() {
|
||||||
proc::GraphItemType::Download => {
|
proc::GraphItemType::Download => {
|
||||||
graph_obj.color = Some("#ff8888ff".into())
|
text += &("<span color=\"#ff8888ff\">".to_owned()
|
||||||
|
+ &item.get_value().to_string()
|
||||||
|
+ "</span>");
|
||||||
}
|
}
|
||||||
proc::GraphItemType::Upload => {
|
proc::GraphItemType::Upload => {
|
||||||
graph_obj.color = Some("#88ff88ff".into())
|
text += &("<span color=\"#88ff88ff\">".to_owned()
|
||||||
|
+ &item.get_value().to_string()
|
||||||
|
+ "</span>");
|
||||||
}
|
}
|
||||||
proc::GraphItemType::Both => graph_obj.color = Some("#ffff88ff".into()),
|
proc::GraphItemType::Both => {
|
||||||
|
text += &("<span color=\"#ffff88ff\">".to_owned()
|
||||||
|
+ &item.get_value().to_string()
|
||||||
|
+ "</span>");
|
||||||
}
|
}
|
||||||
graph_obj.full_text = item.get_value().into();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
graph_obj.full_text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(down_object) = array.get_by_name_mut("net_down") {
|
if let Some(down_object) = array.get_by_name_mut("net_down") {
|
||||||
|
|
Loading…
Reference in a new issue