use chrono::NaiveTime; use i3monkit::{ColorRGB, Header, I3Protocol, WidgetCollection}; use i3xs::widgets::{ cpu::CpuWidget, datetime::{DateTimeWidget, TimeColor}, network::NetworkSpeedWidget, power::PowerSupply, }; use structopt::StructOpt; #[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(); bar.push(PowerSupply::default()); bar.push(CpuWidget::default()); // Realtime upload/download rate for a interface bar.push(NetworkSpeedWidget::new(&opts.nic, 6)); let mut dt = DateTimeWidget::new("%m/%d %H:%M"); dt.set_colors(vec![ TimeColor { start: NaiveTime::from_hms_opt(19, 0, 0).unwrap(), color: ColorRGB::yellow(), }, TimeColor { start: NaiveTime::from_hms_opt(20, 0, 0).unwrap(), color: ColorRGB::red(), }, ]); bar.push(dt); // Then start updating the status bar bar.update_loop(I3Protocol::new(Header::new(1), std::io::stdout())); }