diff --git a/overlays/pkgs/sway-helper/src/commands/rename_workspace.rs b/overlays/pkgs/sway-helper/src/commands/rename_workspace.rs index a41d21d..3cb7c79 100644 --- a/overlays/pkgs/sway-helper/src/commands/rename_workspace.rs +++ b/overlays/pkgs/sway-helper/src/commands/rename_workspace.rs @@ -7,14 +7,19 @@ impl CliRun for RenameWorkspace { fn run(&self) { let mut sway = swayipc::Connection::new().unwrap(); + // Get a list of all the workspace names, with the focused workspace at the front (allowing + // fastest access to editing). let workspace_names = crate::helpers::get_workspace_names(&mut sway, FocusedWorkspacePosition::Front); + // Fuzzy select a workspace. let selected = crate::helpers::do_fzf(workspace_names); + // Get a new name for the workspace. let new_name = edit::edit(selected.clone()).unwrap(); let new_name = new_name.trim(); + // Rename the workspace. sway.run_command(format!("rename workspace \"{selected}\" to \"{new_name}\"")) .unwrap(); } diff --git a/overlays/pkgs/sway-helper/src/commands/switch_to_workspace.rs b/overlays/pkgs/sway-helper/src/commands/switch_to_workspace.rs index cc63d81..9b9b973 100644 --- a/overlays/pkgs/sway-helper/src/commands/switch_to_workspace.rs +++ b/overlays/pkgs/sway-helper/src/commands/switch_to_workspace.rs @@ -7,14 +7,20 @@ impl CliRun for SwitchToWorkspace { fn run(&self) { let mut sway = swayipc::Connection::new().unwrap(); + // Add "back_and_forth" at the start of the list to allow very fast switching between the + // last two focused workspaces. let mut workspace_names = vec!["back_and_forth".to_string()]; + + // Add the names of all the workspaces, with the name of the current workspace at the back. workspace_names.append(&mut crate::helpers::get_workspace_names( &mut sway, FocusedWorkspacePosition::Back, )); + // Fuzzy select a workspace. let selected = crate::helpers::do_fzf(workspace_names); + // Switch to the selected workspace. sway.run_command(format!("workspace {selected}")).unwrap(); } }