From 9163582d343e7f54704c935a927d5e39626ec1ec Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 5 Nov 2021 08:46:41 +0100 Subject: [PATCH] Allow s: shortcut in execute-swaymsg-command --- NEWS.md | 2 ++ src/cmds.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index bc7063f..7ae1a26 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,8 @@ swayr v0.9.0 - `s:`: Executes the sway command `` using `swaymsg`. - Any other input is assumed to be a workspace name and thus handled as `w:` would do. +- The command `execute-swaymsg-command` executes non-matching input as + described by the `s:` shortcut above. - There's a new command `move-focused-to-workspace` which moves the currently focused window or container to another workspace selected with the menu program. Non-matching input of the form `#w:` where the hash and diff --git a/src/cmds.rs b/src/cmds.rs index 3dabb45..f0304e2 100644 --- a/src/cmds.rs +++ b/src/cmds.rs @@ -426,6 +426,13 @@ fn chop_workspace_shortcut(input: &str) -> &str { } } +fn chop_sway_shortcut(input: &str) -> &str { + match SPECIAL_SWAY.captures(input) { + Some(c) => c.get(1).unwrap().as_str(), + None => input, + } +} + fn handle_non_matching_input(input: &str) { if input.is_empty() { return; @@ -840,6 +847,7 @@ pub fn exec_swaymsg_command() { match cmd { Ok(cmd) => run_sway_command(&cmd.cmd), Err(cmd) if !cmd.is_empty() => { + let cmd = chop_sway_shortcut(&cmd); run_sway_command( &cmd.split_ascii_whitespace().collect::>(), );