Skip to content

Commit

Permalink
fix: capture output (display) for debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
roosta committed Dec 15, 2024
1 parent 167d8ca commit 49e3bf5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,25 @@ pub fn get_title(
pub fn get_workspaces(tree: Node) -> Vec<Node> {
let excludes = ["__i3_scratch"];
tree.nodes.into_iter() // outputs
.flat_map(|output| output.nodes) // containers
.flat_map(|container| container.nodes) // workspaces
.filter(|node| matches!(node.node_type, NodeType::Workspace))
.filter(|workspace| {
.flat_map(|output| {
output.nodes.into_iter().map(move |container| {
// Preserve output information for each workspace
(output.name.as_ref().map(String::from), container)
})
})
.flat_map(|(output_name, container)| {
container.nodes.into_iter().map(move |workspace| {
// Attach output name to each workspace
(output_name.clone(), workspace)
})
})
.filter(|(_, node)| matches!(node.node_type, NodeType::Workspace))
.filter(|(_, workspace)| {
workspace.name.as_ref()
.map(|name| !excludes.contains(&name.as_str()))
.unwrap_or(false)
})
.map(|(_, workspace)| workspace)
.collect()
}

Expand Down Expand Up @@ -343,6 +354,9 @@ pub fn update_tree(
let command = format!("rename workspace \"{}\" to \"{}\"", old, new);
if VERBOSE.load(Ordering::Relaxed) {
println!("{} {}", "[COMMAND]".blue(), command);
if let Some(output) = &workspace.output {
println!("{} Workspace on output: {}", "[INFO]".cyan(), output);
}
}
conn.run_command(command)?;
}
Expand Down

0 comments on commit 49e3bf5

Please sign in to comment.