diff --git a/crates/eww/src/ipc_server.rs b/crates/eww/src/ipc_server.rs index ac1e116..2faadfe 100644 --- a/crates/eww/src/ipc_server.rs +++ b/crates/eww/src/ipc_server.rs @@ -38,7 +38,7 @@ async fn handle_connection(mut stream: tokio::net::UnixStream, evt_send: Unbound evt_send.send(command)?; if let Some(mut response_recv) = maybe_response_recv { - log::info!("Waiting for response for IPC client"); + log::debug!("Waiting for response for IPC client"); if let Ok(Some(response)) = tokio::time::timeout(Duration::from_millis(100), response_recv.recv()).await { let response = bincode::serialize(&response)?; let result = &stream_write.write_all(&response).await; diff --git a/crates/eww/src/main.rs b/crates/eww/src/main.rs index f1b7466..41c53ad 100644 --- a/crates/eww/src/main.rs +++ b/crates/eww/src/main.rs @@ -66,6 +66,11 @@ fn main() { // a running daemon is necessary for this command opts::Action::WithServer(action) if action.can_start_daemon() => { + if opts.restart { + let _ = handle_server_command(&paths, &ActionWithServer::KillServer, 1); + std::thread::sleep(std::time::Duration::from_millis(200)); + } + // attempt to just send the command to a running daemon if let Err(err) = handle_server_command(&paths, &action, 5) { // connecting to the daemon failed. Thus, start the daemon here! @@ -78,7 +83,6 @@ fn main() { let (command, response_recv) = action.into_daemon_command(); // start the daemon and give it the command - let fork_result = server::initialize_server(paths.clone(), Some(command))?; let is_parent = fork_result == ForkResult::Parent; if let (Some(recv), true) = (response_recv, is_parent) { diff --git a/crates/eww/src/opts.rs b/crates/eww/src/opts.rs index e93fb7b..3925ed4 100644 --- a/crates/eww/src/opts.rs +++ b/crates/eww/src/opts.rs @@ -15,6 +15,7 @@ use crate::{ pub struct Opt { pub log_debug: bool, pub show_logs: bool, + pub restart: bool, pub config_path: Option, pub action: Action, } @@ -33,6 +34,10 @@ struct RawOpt { #[structopt(long = "logs", global = true)] show_logs: bool, + /// Restart the daemon completely before running the command + #[structopt(long = "restart", global = true)] + restart: bool, + #[structopt(subcommand)] action: Action, } @@ -148,8 +153,8 @@ impl Opt { impl From for Opt { fn from(other: RawOpt) -> Self { - let RawOpt { action, log_debug, show_logs, config } = other; - Opt { action, log_debug, show_logs, config_path: config } + let RawOpt { action, log_debug, show_logs, config, restart } = other; + Opt { action, log_debug, show_logs, config_path: config, restart } } }