From 1a2ad57826b4c0f56b046dd012b2cafe64ad9a2a Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sat, 21 Sep 2019 20:48:04 -0700 Subject: [PATCH] Split binaries into work and home version. --- Cargo.toml | 9 +++++++-- src/bin/home.rs | 35 +++++++++++++++++++++++++++++++++++ src/bin/{main.rs => work.rs} | 7 ++++--- 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/bin/home.rs rename src/bin/{main.rs => work.rs} (83%) diff --git a/Cargo.toml b/Cargo.toml index 8ca99fc..2675270 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,12 @@ name = "i3xs" path = "src/lib.rs" [[bin]] -name = "i3xs" -path = "src/bin/main.rs" +name = "i3xs-work" +path = "src/bin/work.rs" + +[[bin]] +name = "i3xs-home" +path = "src/bin/home.rs" [dependencies] i3monkit = "0.1.2" @@ -20,3 +24,4 @@ num_cpus = "1.0" structopt = { version = "0.2", default-features = false } chrono = "0.4" chrono-tz = "0.5" +spark = "0.4.0" diff --git a/src/bin/home.rs b/src/bin/home.rs new file mode 100644 index 0000000..c139f73 --- /dev/null +++ b/src/bin/home.rs @@ -0,0 +1,35 @@ +use i3monkit::widgets::CpuWidget; +use i3monkit::{Header, I3Protocol, WidgetCollection}; + +use num_cpus; + +use structopt::StructOpt; + +use i3xs::widgets::datetime::DateTimeWidget; +use i3xs::widgets::network::NetworkSpeedWidget; + +#[derive(Debug, StructOpt)] +#[structopt(name = "i3xs", about = "Custom i3 status bar program.")] +struct Opt { + #[structopt(short, long)] + nic: String, +} + +fn main() { + let mut bar = WidgetCollection::new(); + + let opts = Opt::from_args(); + + //Display all the cpu usage for each core + for i in 0..num_cpus::get() as u32 { + bar.push(CpuWidget::new(i)); + } + + // Realtime upload/download rate for a interface + bar.push(NetworkSpeedWidget::new(&opts.nic)); + + bar.push(DateTimeWidget::new("%m/%d %H:%M".to_string())); + + // Then start updating the status bar + bar.update_loop(I3Protocol::new(Header::new(1), std::io::stdout())); +} diff --git a/src/bin/main.rs b/src/bin/work.rs similarity index 83% rename from src/bin/main.rs rename to src/bin/work.rs index d43b86c..e329d4b 100644 --- a/src/bin/main.rs +++ b/src/bin/work.rs @@ -1,11 +1,12 @@ -use i3monkit::widgets::{CpuWidget, NetworkSpeedWidget}; +use i3monkit::widgets::CpuWidget; use i3monkit::{Header, I3Protocol, WidgetCollection}; use num_cpus; use structopt::StructOpt; -use i3xs::widgets::DateTimeWidget; +use i3xs::widgets::datetime::DateTimeWidget; +use i3xs::widgets::network::NetworkSpeedWidget; #[derive(Debug, StructOpt)] #[structopt(name = "i3xs", about = "Custom i3 status bar program.")] @@ -33,6 +34,6 @@ fn main() { )); bar.push(DateTimeWidget::new("%m/%d %H:%M".to_string())); - // Then start updating the satus bar + // Then start updating the status bar bar.update_loop(I3Protocol::new(Header::new(1), std::io::stdout())); }