diff --git a/src/app.rs b/src/app.rs index 864fe39..53210f8 100644 --- a/src/app.rs +++ b/src/app.rs @@ -29,6 +29,7 @@ pub enum EwwCommand { window_name: WindowName, }, KillServer, + CloseAll, PrintState(crossbeam_channel::Sender), PrintDebug(crossbeam_channel::Sender), } @@ -81,6 +82,12 @@ impl App { script_var_process::on_application_death(); std::process::exit(0); } + EwwCommand::CloseAll => { + log::info!("Received close command, closing all windows"); + for (window_name, _window) in self.windows.clone() { + self.close_window(&window_name)?; + } + } EwwCommand::OpenWindow { window_name, pos, diff --git a/src/opts.rs b/src/opts.rs index 0863150..a4f681d 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -84,6 +84,10 @@ pub enum ActionWithServer { #[structopt(name = "kill")] KillServer, + /// Close all windows, without killing the daemon + #[structopt(name = "close-all")] + CloseAll, + /// Print the current eww-state #[structopt(name = "state")] ShowState, @@ -139,6 +143,7 @@ impl ActionWithServer { }, ActionWithServer::CloseWindow { window_name } => app::EwwCommand::CloseWindow { window_name }, ActionWithServer::KillServer => app::EwwCommand::KillServer, + ActionWithServer::CloseAll => app::EwwCommand::CloseAll, ActionWithServer::ShowState => { let (send, recv) = crossbeam_channel::unbounded(); return (app::EwwCommand::PrintState(send), Some(recv));