diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2023-03-31 21:06:35 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2023-03-31 21:06:35 +0300 |
| commit | 91381b2c1bb0ee5cb4755ac80769a7838874bbe6 (patch) | |
| tree | 3d22527c78d6bcdb8b6e77dddcea02e81a36c504 /src/state.rs | |
| parent | 4d23983c1f048c2301bf464ba949d578b98d4426 (diff) | |
| download | i3bar-mango-91381b2c1bb0ee5cb4755ac80769a7838874bbe6.tar.gz | |
poll() instead of tokio
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/state.rs b/src/state.rs index 53ef4ff..4741efa 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,7 +1,8 @@ use crate::protocol::*; use crate::wm_info_provider::*; -use std::future::pending; +use std::fmt::Display; +use std::os::fd::{AsRawFd, RawFd}; use wayrs_client::connection::Connection; use wayrs_client::global::{Global, GlobalExt, Globals, GlobalsExt}; @@ -108,11 +109,11 @@ impl State { self.draw_all(conn); } - pub fn set_error(&mut self, conn: &mut Connection<Self>, error: impl Into<String>) { + pub fn set_error(&mut self, conn: &mut Connection<Self>, error: impl Display) { self.set_blocks( conn, vec![Block { - full_text: error.into(), + full_text: error.to_string(), ..Default::default() }], ); @@ -124,26 +125,11 @@ impl State { } } - pub async fn status_cmd_read(&mut self) -> anyhow::Result<()> { - match &mut self.shared_state.status_cmd { - Some(cmd) => cmd.read().await, - None => { - pending::<()>().await; - unreachable!() - } - } - } - - pub fn status_cmd_notify_available( - &mut self, - conn: &mut Connection<Self>, - ) -> anyhow::Result<()> { - if let Some(cmd) = &mut self.shared_state.status_cmd { - if let Some(blocks) = cmd.notify_available()? { - self.set_blocks(conn, blocks); - } - } - Ok(()) + pub fn status_cmd_fd(&self) -> Option<RawFd> { + self.shared_state + .status_cmd + .as_ref() + .map(|cmd| cmd.output.as_raw_fd()) } fn bind_output(&mut self, conn: &mut Connection<Self>, global: &Global) { |
