Use 'workspace number' feature of sway

This allows compatibility with e.g. `sworkstyle`, as we don't rely on
workspace names any more.
This commit is contained in:
Skia 2021-09-07 16:50:15 +02:00
parent 25c7a2cc62
commit ee9750fc57

View file

@ -150,18 +150,20 @@ fn get_current_output_name(stream: &UnixStream) -> String {
} }
fn move_container_to_workspace(stream: &UnixStream, workspace_name: &String) { fn move_container_to_workspace(stream: &UnixStream, workspace_name: &String) {
let mut cmd: String = "move container to workspace ".to_string(); let mut cmd: String = "move container to workspace number ".to_string();
let output = get_current_output_index(stream); let full_ws_name = format!("{}{}", get_current_output_index(stream), &workspace_name)
cmd.push_str(&output); .parse::<i32>()
cmd.push_str(&workspace_name); .unwrap();
cmd.push_str(&full_ws_name.to_string());
send_command(&stream, &cmd); send_command(&stream, &cmd);
} }
fn focus_to_workspace(stream: &UnixStream, workspace_name: &String) { fn focus_to_workspace(stream: &UnixStream, workspace_name: &String) {
let mut cmd: String = "workspace ".to_string(); let mut cmd: String = "workspace number ".to_string();
let output = get_current_output_index(stream); let full_ws_name = format!("{}{}", get_current_output_index(stream), &workspace_name)
cmd.push_str(&output); .parse::<i32>()
cmd.push_str(&workspace_name); .unwrap();
cmd.push_str(&full_ws_name.to_string());
send_command(&stream, &cmd); send_command(&stream, &cmd);
} }
@ -219,13 +221,13 @@ fn move_container_to_next_or_prev_output(stream: &UnixStream, go_to_prev: bool)
.unwrap(); .unwrap();
// Move container to target workspace // Move container to target workspace
let mut cmd: String = "move container to workspace ".to_string(); let mut cmd: String = "move container to workspace number ".to_string();
cmd.push_str(&target_workspace["name"].as_str().unwrap()); cmd.push_str(&target_workspace["num"].to_string());
send_command(&stream, &cmd); send_command(&stream, &cmd);
// Focus that workspace to follow the container // Focus that workspace to follow the container
let mut cmd: String = "workspace ".to_string(); let mut cmd: String = "workspace number ".to_string();
cmd.push_str(&target_workspace["name"].as_str().unwrap()); cmd.push_str(&target_workspace["num"].to_string());
send_command(&stream, &cmd); send_command(&stream, &cmd);
} }