Skip to content

Commit

Permalink
Replace eww windows with active-windows and list-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
elkowar authored and WilfSilver committed Aug 18, 2023
1 parent 60d450a commit f4031b8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 9 additions & 12 deletions crates/eww/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ pub enum DaemonCommand {
},
PrintDebug(DaemonResponseSender),
PrintGraph(DaemonResponseSender),
PrintWindows(DaemonResponseSender),
ListWindows(DaemonResponseSender),
ListActiveWindows(DaemonResponseSender),
}

/// An opened window.
Expand Down Expand Up @@ -113,7 +114,7 @@ pub struct App<B> {
pub display_backend: B,
pub scope_graph: Rc<RefCell<ScopeGraph>>,
pub eww_config: config::EwwConfig,
/// Map of all currently open windows
/// Map of all currently open windows by their IDs
pub open_windows: HashMap<String, EwwWindow>,
pub instance_id_to_args: HashMap<String, WindowArguments>,
/// Window names that are supposed to be open, but failed.
Expand Down Expand Up @@ -270,16 +271,12 @@ impl<B: DisplayBackend> App<B> {
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) => {
Expand Down
13 changes: 9 additions & 4 deletions crates/eww/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<window_id>: <window_name>`
#[command(name = "active-windows")]
ListActiveWindows,

/// Print out the widget structure as seen by eww.
///
Expand Down Expand Up @@ -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 })
}
Expand Down
2 changes: 1 addition & 1 deletion crates/eww/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn initialize_server<B: DisplayBackend>(
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(),
Expand Down

0 comments on commit f4031b8

Please sign in to comment.