Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Aug 18, 2024
1 parent b6d1b54 commit bb752ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions overlays/pkgs/sway-helper/src/commands/rename_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 6 additions & 0 deletions overlays/pkgs/sway-helper/src/commands/switch_to_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit bb752ed

Please sign in to comment.