36 lines
890 B
Rust
36 lines
890 B
Rust
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()));
|
|
}
|