diff --git a/CHANGELOG.md b/CHANGELOG.md index 722c288d..9181e1c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to eww will be listed here, starting at changes since versio ## [Unreleased] +### BREAKING CHANGES +- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows` + ### Features - Add `:namespace` window option - Default to building with x11 and wayland support simultaneously diff --git a/crates/eww/src/app.rs b/crates/eww/src/app.rs index 44ed96d0..8d36435c 100644 --- a/crates/eww/src/app.rs +++ b/crates/eww/src/app.rs @@ -79,7 +79,8 @@ pub enum DaemonCommand { }, PrintDebug(DaemonResponseSender), PrintGraph(DaemonResponseSender), - PrintWindows(DaemonResponseSender), + ListWindows(DaemonResponseSender), + ListActiveWindows(DaemonResponseSender), } /// An opened window. @@ -113,7 +114,7 @@ pub struct App { pub display_backend: B, pub scope_graph: Rc>, pub eww_config: config::EwwConfig, - /// Map of all currently open windows + /// Map of all currently open windows by their IDs pub open_windows: HashMap, pub instance_id_to_args: HashMap, /// Window names that are supposed to be open, but failed. @@ -270,16 +271,12 @@ impl App { None => sender.send_failure(format!("Variable not found \"{}\"", name))?, } } - DaemonCommand::PrintWindows(sender) => { - let output = self - .eww_config - .get_windows() - .keys() - .map(|window_name| { - let is_open = self.open_windows.contains_key(window_name); - format!("{}{}", if is_open { "*" } else { "" }, window_name) - }) - .join("\n"); + DaemonCommand::ListWindows(sender) => { + let output = self.eww_config.get_windows().keys().join("\n"); + sender.send_success(output)? + } + DaemonCommand::ListActiveWindows(sender) => { + let output = self.open_windows.iter().map(|(id, window)| format!("{id}: {}", window.name)).join("\n"); sender.send_success(output)? } DaemonCommand::PrintDebug(sender) => { diff --git a/crates/eww/src/opts.rs b/crates/eww/src/opts.rs index df6f159c..39420fbd 100644 --- a/crates/eww/src/opts.rs +++ b/crates/eww/src/opts.rs @@ -179,9 +179,13 @@ pub enum ActionWithServer { #[command(name = "get")] GetVar { name: String }, - /// Print the names of all configured windows. Windows with a * in front of them are currently opened. - #[command(name = "windows")] - ShowWindows, + /// List the names of active windows + #[command(name = "list-windows")] + ListWindows, + + /// Show active window IDs, formatted linewise `: ` + #[command(name = "active-windows")] + ListActiveWindows, /// Print out the widget structure as seen by eww. /// @@ -273,7 +277,8 @@ impl ActionWithServer { return with_response_channel(|sender| app::DaemonCommand::CloseWindows { windows, sender }); } ActionWithServer::Reload => return with_response_channel(app::DaemonCommand::ReloadConfigAndCss), - ActionWithServer::ShowWindows => return with_response_channel(app::DaemonCommand::PrintWindows), + ActionWithServer::ListWindows => return with_response_channel(app::DaemonCommand::ListWindows), + ActionWithServer::ListActiveWindows => return with_response_channel(app::DaemonCommand::ListActiveWindows), ActionWithServer::ShowState { all } => { return with_response_channel(|sender| app::DaemonCommand::PrintState { all, sender }) } diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index feebfce2..5a7ecc87 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -81,7 +81,7 @@ pub fn initialize_server( eww_config, open_windows: HashMap::new(), failed_windows: HashSet::new(), - window_argumentss: HashMap::new(), + instance_id_to_args: HashMap::new(), css_provider: gtk::CssProvider::new(), script_var_handler, app_evt_send: ui_send.clone(),