From a8689994ea3097b31b636b75d242a08a912a5b59 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 11 Dec 2021 20:56:06 +0100 Subject: [PATCH] Release 0.11.1 with new switch-to command --- Cargo.lock | 2 +- Cargo.toml | 2 +- NEWS.md | 8 ++++++++ README.md | 2 ++ src/cmds.rs | 13 +++++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07f7186..5eb0e1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,7 +359,7 @@ dependencies = [ [[package]] name = "swayr" -version = "0.11.0" +version = "0.11.1" dependencies = [ "clap", "directories", diff --git a/Cargo.toml b/Cargo.toml index a80b2bd..8de2437 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swayr" -version = "0.11.0" +version = "0.11.1" description = "A LRU window-switcher (and more) for the sway window manager" homepage = "https://sr.ht/~tsdh/swayr/" repository = "https://git.sr.ht/~tsdh/swayr" diff --git a/NEWS.md b/NEWS.md index f87749b..1dee913 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +swayr v0.11.1 +============= + +- Well, bumping the micro version usually indicates a bugfix release but I've + forgotten to add the `switch-to` command in version 0.11.0. It's the + canonical "switch to anything" command, i.e., it offers outputs, workspaces, + containers, and windows. + swayr v0.11.0 ============= diff --git a/README.md b/README.md index 01b2599..cae33d2 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Right now, there are these subcommands: switches to the selected workspace or window. * `switch-workspace-container-or-window` shows workspaces, containers, and their windows in the menu program and switches to the selected one. +* `switch-to` shows outputs, workspaces, containers, and their windows in the + menu program and switches to the selected one. * `quit-window` displays all windows and quits the selected one. * `quit-workspace-or-window` displays all workspaces and their windows and allows to quit either the selected workspace (all its windows) or the diff --git a/src/cmds.rs b/src/cmds.rs index e741fd0..52e4352 100644 --- a/src/cmds.rs +++ b/src/cmds.rs @@ -78,6 +78,9 @@ pub enum SwayrCommand { /// Switch to the selected workspace or focus the selected container, or /// window. SwitchWorkspaceContainerOrWindow, + /// Switch to the selected output or workspace or focus the selected + /// container, or window. + SwitchTo, /// Quit the selected window. QuitWindow, /// Quit all windows of selected workspace or the selected window. @@ -250,6 +253,7 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { SwayrCommand::SwitchWorkspaceContainerOrWindow => { switch_workspace_container_or_window(&*props.read().unwrap()) } + SwayrCommand::SwitchTo => switch_to(&*props.read().unwrap()), SwayrCommand::QuitWindow => quit_window(&*props.read().unwrap()), SwayrCommand::QuitWorkspaceOrWindow => { quit_workspace_or_window(&*props.read().unwrap()) @@ -580,6 +584,15 @@ pub fn switch_workspace_container_or_window( ); } +pub fn switch_to(extra_props: &HashMap) { + let root = get_tree(true); + let tree = t::get_tree(&root, extra_props); + select_and_focus( + "Select output, workspace, container or window", + &tree.get_outputs_workspaces_containers_and_windows(), + ); +} + fn select_and_quit(prompt: &str, choices: &[t::DisplayNode]) { if let Ok(tn) = util::select_from_menu(prompt, choices) { match tn.node.get_type() {