blob: 7f8dd38a1fc36acd4880466fad222a9d33eede43 (
plain) (
blame)
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
|
#[macro_use]
extern crate anyhow;
#[macro_use]
extern crate log;
mod bar;
mod button_manager;
mod color;
mod config;
mod i3bar_protocol;
mod ord_adaptor;
mod pointer_btn;
mod river_protocols;
mod shared_state;
mod state;
mod status_cmd;
mod tags;
mod text;
mod utils;
use smithay_client_toolkit::reexports::client::Connection;
use tokio::io::{unix::AsyncFd, Interest};
use state::State;
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
env_logger::init();
let conn = Connection::connect_to_env()?;
let mut event_queue = conn.new_event_queue();
let mut state = State::new(&conn, &mut event_queue);
let async_fd = AsyncFd::with_interest(
event_queue.prepare_read()?.connection_fd(),
Interest::READABLE,
)?;
event_queue.roundtrip(&mut state)?;
event_queue.flush()?;
loop {
tokio::select! {
readable = async_fd.readable() => {
readable?.clear_ready();
event_queue.prepare_read()?.read()?;
event_queue.dispatch_pending(&mut state)?;
event_queue.flush()?;
}
readable = state.wait_for_status_cmd() => {
readable?.clear_ready();
if let Err(e) = state.notify_available() {
if let Some(mut status_cmd) = state.shared_state.status_cmd.take() {
let _ = status_cmd.child.kill();
}
state.set_error(e.to_string());
state.draw_all();
}
event_queue.flush()?;
}
}
}
}
|