1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (C) 2019, Hao Hou
//! # i3monkit - The i3 Status Bar Monitor Toolkit
//!
//! This is a toolkit for building customized i3 status bar for the [i3 tiling window manager](https://i3wm.org).
//! i3 has its default status bar program called `i3status`, but it's somehow limited and hard to
//! extend and customize. This crate gives you the ability to reimplement an status bar program for
//! i3 quickly.
//!
//! 
//!
//! It comes with a set of builtin widget as well, such as, CPU usage bar, Network speed meter,
//! etc.
//!
//! You can crate your own status bar with just a few lines of code in Rust.
//!
//! First, you need to crate a crate and import this crate
//!
//! ```toml
//! [dependencies]
//! i3mokit = "*"
//!
//! ```
//!
//! Then, config your customized i3 status bar
//!
//! ```rust
//! use i3monkit::*;
//! use i3monkit::widgets::*;
//!
//! fn main() {
//! let mut bar = WidgetCollection::new();
//!
//! //Add realtime stock prices, for example: Microsoft, AMD and Facebook
//! let stock_client = StockClient::new("your-alphavantage-API-key");
//! bar.push(StockClient::create_widget(&stock_client, "MSFT"));
//! bar.push(StockClient::create_widget(&stock_client, "AMD"));
//! bar.push(StockClient::create_widget(&stock_client, "FB"));
//!
//! //Realtime upload/download rate for a interface
//! bar.push(NetworkSpeedWidget::new("wlp58s0"));
//!
//! //Display all the cpu usage for each core
//! for i in 0..4 {
//! bar.push(CpuWidget::new(i));
//! }
//!
//! //Volume widget
//! bar.push(VolumeWidget::new("default", "Master", 0));
//!
//! //Battery status
//! bar.push(BatteryWidget::new(0));
//!
//! //Time
//! bar.push(DateTimeWidget::new());
//!
//! // Then start updating the satus bar
//! bar.update_loop(I3Protocol::new(Header::new(1), std::io::stdout()));
//! }
//! ```
//!
//! Finally, you can change `~/.config/i3/config` to make i3wm uses your status bar program
//!
//! ``` config
//! # Start i3bar to display a workspace bar (plus the system information i3status
//! # finds out, if available)
//! bar {
//! status_command path/to/your/customized/status/program
//! tray_output primary
//! colors {
//! background #222222
//! statusline #00ee22
//! separator #666666
//! # border backgr. text
//! focused_workspace #4c7899 #285577 #ffffff
//! inactive_workspace #333333 #222222 #888888
//! urgent_workspace #2f343a #900000 #ffffff
//! }
//! }
//! ```
//! ## Write your own widget
//!
//! You can also add your customized widget to the framework by implementing the `Widget` trait.
//!
//! ```
//! use i3monkit::{Block, Widget, WidgetUpdate};
//! struct Greeter(&'static str);
//! impl Widget for Greeter {
//! fn update(&mut self) -> Option<WidgetUpdate> {
//! Some(WidgetUpdate{
//! refresh_interval: std::time::Duration::new(3600,0),
//! data: Some(Block::new().append_full_text(self.0).clone())
//! })
//! }
//! }
//!
//! fn main() {
//! let bar = WidgetCollection::new();
//! bar.push(Greeter("hello world"));
//! .....
//! }
//! ```
//!
pub use crate;
pub use crate;