changed stuff
This commit is contained in:
Regular → Executable
+32
-3
@@ -42,15 +42,15 @@ async fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
while let Some(event) = workspace_event_rx.recv().await {
|
while let Some(event) = workspace_event_rx.recv().await {
|
||||||
if let SwayEvent::Window(window_event) = event {
|
|
||||||
if let WindowChangeType::New = window_event.change {
|
|
||||||
let sway_ipc_clone = sway_ipc.clone();
|
let sway_ipc_clone = sway_ipc.clone();
|
||||||
|
|
||||||
// Handle the new layout setup
|
// Handle the new layout setup
|
||||||
let root = sway_ipc_clone.get_tree().await.unwrap();
|
let root = sway_ipc_clone.get_tree().await.unwrap();
|
||||||
let workspaces = sway_ipc_clone.get_workspaces().await.unwrap();
|
let workspaces = sway_ipc_clone.get_workspaces().await.unwrap();
|
||||||
let leaves = get_current_leaves_here(&root, &workspaces);
|
let leaves = get_current_leaves_here(&root, &workspaces);
|
||||||
|
if let SwayEvent::Window(window_event) = event {
|
||||||
|
match window_event.change {
|
||||||
|
WindowChangeType::New => {
|
||||||
if let (Some(first), Some(second)) = (leaves.first(), leaves.get(1)) {
|
if let (Some(first), Some(second)) = (leaves.first(), leaves.get(1)) {
|
||||||
let mut command = format!("[con_id={}] splith", first.id);
|
let mut command = format!("[con_id={}] splith", first.id);
|
||||||
match leaves.get(2) {
|
match leaves.get(2) {
|
||||||
@@ -67,6 +67,35 @@ async fn main() {
|
|||||||
sway_ipc_clone.run_command(command).await.unwrap();
|
sway_ipc_clone.run_command(command).await.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WindowChangeType::Close => {
|
||||||
|
println!("❌ Window closed: ID {}", window_event.container.id);
|
||||||
|
|
||||||
|
if let Some(master) = leaves.first() {
|
||||||
|
println!("🔍 Current Master ID before closing: {}", master.id);
|
||||||
|
} else {
|
||||||
|
println!("⚠️ No Master found in current workspace!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if leaves
|
||||||
|
.first()
|
||||||
|
.map_or(false, |master| master.id == window_event.container.id)
|
||||||
|
{
|
||||||
|
println!("🔥 Master was closed! Promoting next container...");
|
||||||
|
|
||||||
|
let command = "
|
||||||
|
focus right;
|
||||||
|
layout splitv;
|
||||||
|
focus left;
|
||||||
|
move up;
|
||||||
|
layout splith;
|
||||||
|
";
|
||||||
|
sway_ipc_clone.run_command(command.to_string()).await.unwrap();
|
||||||
|
} else {
|
||||||
|
println!("✅ Closed window was NOT the Master. No action needed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Regular → Executable
Reference in New Issue
Block a user