diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2023-06-01 13:23:26 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2023-06-01 13:23:26 +0300 |
| commit | 84b8dfe8cd190de33221f465a7059be6a30769f5 (patch) | |
| tree | ab7b9e7b537858a5aa6376be6b8355c723f0fdec /src/status_cmd.rs | |
| parent | f11240cb1e30e494be840d2ecef8504dd8cea7ff (diff) | |
| download | i3bar-mango-84b8dfe8cd190de33221f465a7059be6a30769f5.tar.gz | |
small changes
Diffstat (limited to 'src/status_cmd.rs')
| -rw-r--r-- | src/status_cmd.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/status_cmd.rs b/src/status_cmd.rs index 172bee2..476204e 100644 --- a/src/status_cmd.rs +++ b/src/status_cmd.rs @@ -1,4 +1,4 @@ -use std::io::Write; +use std::io::{BufWriter, Write}; use std::os::fd::{AsRawFd, RawFd}; use std::process::{Child, ChildStdin, ChildStdout, Command, Stdio}; @@ -13,7 +13,7 @@ use crate::i3bar_protocol::{Block, Event, Protocol}; pub struct StatusCmd { pub child: Child, pub output: ChildStdout, - input: ChildStdin, + input: BufWriter<ChildStdin>, protocol: Protocol, buf: Vec<u8>, } @@ -26,7 +26,7 @@ impl StatusCmd { .stdout(Stdio::piped()) .spawn()?; let output = child.stdout.take().unwrap(); - let input = child.stdin.take().unwrap(); + let input = BufWriter::new(child.stdin.take().unwrap()); nix::fcntl::fcntl( output.as_raw_fd(), nix::fcntl::F_SETFL(nix::fcntl::OFlag::O_NONBLOCK), @@ -57,7 +57,9 @@ impl StatusCmd { pub fn send_click_event(&mut self, event: &Event) -> Result<()> { if self.protocol.supports_clicks() { - writeln!(self.input, "{}", serde_json::to_string(event)?)?; + serde_json::to_writer(&mut self.input, event)?; + self.input.write_all(b"\n")?; + self.input.flush()?; } Ok(()) } |
