aboutsummaryrefslogtreecommitdiff
path: root/src/run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/run.rs')
-rw-r--r--src/run.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/run.rs b/src/run.rs
index c6c72a6..141e32d 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -1,12 +1,10 @@
+use crate::config::CONFIG;
use crate::types::*;
use crate::utils::*;
-use crate::config::CONFIG;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
-/* This is ugly, maybe i will try to impliment a threadpool */
-
pub fn run(mut blocks: Blocks) {
let (tx, rx) = mpsc::channel();
@@ -49,6 +47,16 @@ pub fn run(mut blocks: Blocks) {
});
}
+ // net speed thread
+ if CONFIG.netspeed.enabled {
+ let net_tx = tx.clone();
+ thread::spawn(move || loop {
+ // get_netspeed will sleep inside the function
+ let net_data = ThreadsData::NetSpeed(netspeed::get_netspeed());
+ net_tx.send(net_data).unwrap();
+ });
+ }
+
// Disk thread
if CONFIG.disk.enabled {
let disk_tx = tx.clone();
@@ -122,7 +130,7 @@ pub fn run(mut blocks: Blocks) {
//Main
{
// NOTE: order matters to the final format
- let mut bar: Vec<String> = vec![String::from(""); 11];
+ let mut bar: Vec<String> = vec![String::from(""); 12];
//iterating the values recieved from the threads
for data in rx {
match data {
@@ -130,13 +138,14 @@ pub fn run(mut blocks: Blocks) {
ThreadsData::Mpd(x) => bar[1] = x,
ThreadsData::Sound(x) => bar[2] = x,
ThreadsData::Weather(x) => bar[3] = x,
- ThreadsData::Disk(x) => bar[4] = x,
- ThreadsData::Memory(x) => bar[5] = x,
- ThreadsData::CpuTemp(x) => bar[6] = x,
- ThreadsData::LoadAvg(x) => bar[7] = x,
- ThreadsData::Battery(x) => bar[8] = x,
- ThreadsData::Uptime(x) => bar[9] = x,
- ThreadsData::Time(x) => bar[10] = x,
+ ThreadsData::NetSpeed(x) => bar[4] = x,
+ ThreadsData::Disk(x) => bar[5] = x,
+ ThreadsData::Memory(x) => bar[6] = x,
+ ThreadsData::CpuTemp(x) => bar[7] = x,
+ ThreadsData::LoadAvg(x) => bar[8] = x,
+ ThreadsData::Battery(x) => bar[9] = x,
+ ThreadsData::Uptime(x) => bar[10] = x,
+ ThreadsData::Time(x) => bar[11] = x,
}
// match ends here