Allow s: shortcut in execute-swaymsg-command

timeout_old
Tassilo Horn 3 years ago
parent 56013daa60
commit 9163582d34
  1. 2
      NEWS.md
  2. 8
      src/cmds.rs

@ -18,6 +18,8 @@ swayr v0.9.0
- `s:<cmd>`: Executes the sway command `<cmd>` using `swaymsg`. - `s:<cmd>`: Executes the sway command `<cmd>` using `swaymsg`.
- Any other input is assumed to be a workspace name and thus handled as - Any other input is assumed to be a workspace name and thus handled as
`w:<input>` would do. `w:<input>` would do.
- The command `execute-swaymsg-command` executes non-matching input as
described by the `s:<cmd>` shortcut above.
- There's a new command `move-focused-to-workspace` which moves the currently - There's a new command `move-focused-to-workspace` which moves the currently
focused window or container to another workspace selected with the menu focused window or container to another workspace selected with the menu
program. Non-matching input of the form `#w:<workspace>` where the hash and program. Non-matching input of the form `#w:<workspace>` where the hash and

@ -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) { fn handle_non_matching_input(input: &str) {
if input.is_empty() { if input.is_empty() {
return; return;
@ -840,6 +847,7 @@ pub fn exec_swaymsg_command() {
match cmd { match cmd {
Ok(cmd) => run_sway_command(&cmd.cmd), Ok(cmd) => run_sway_command(&cmd.cmd),
Err(cmd) if !cmd.is_empty() => { Err(cmd) if !cmd.is_empty() => {
let cmd = chop_sway_shortcut(&cmd);
run_sway_command( run_sway_command(
&cmd.split_ascii_whitespace().collect::<Vec<&str>>(), &cmd.split_ascii_whitespace().collect::<Vec<&str>>(),
); );

Loading…
Cancel
Save