|
|
@ -110,6 +110,8 @@ pub enum SwayrCommand { |
|
|
|
SwitchWorkspaceOrWindow, |
|
|
|
SwitchWorkspaceOrWindow, |
|
|
|
/// Quit all windows of selected workspace or the selected window.
|
|
|
|
/// Quit all windows of selected workspace or the selected window.
|
|
|
|
QuitWorkspaceOrWindow, |
|
|
|
QuitWorkspaceOrWindow, |
|
|
|
|
|
|
|
/// Move the currently focused window or container to the selected workspace.
|
|
|
|
|
|
|
|
MoveFocusedToWorkspace, |
|
|
|
/// Tab or shuffle-and-tile the windows on the current workspace, including
|
|
|
|
/// Tab or shuffle-and-tile the windows on the current workspace, including
|
|
|
|
/// or excluding floating windows.
|
|
|
|
/// or excluding floating windows.
|
|
|
|
ToggleTabShuffleTileWorkspace { |
|
|
|
ToggleTabShuffleTileWorkspace { |
|
|
@ -278,6 +280,9 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
&*props.read().unwrap(), |
|
|
|
&*props.read().unwrap(), |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SwayrCommand::MoveFocusedToWorkspace => { |
|
|
|
|
|
|
|
move_focused_container_to_workspace(&*props.read().unwrap()) |
|
|
|
|
|
|
|
} |
|
|
|
SwayrCommand::QuitWindow => quit_window(&*props.read().unwrap()), |
|
|
|
SwayrCommand::QuitWindow => quit_window(&*props.read().unwrap()), |
|
|
|
SwayrCommand::SwitchWorkspace => { |
|
|
|
SwayrCommand::SwitchWorkspace => { |
|
|
|
switch_workspace(&*props.read().unwrap()) |
|
|
|
switch_workspace(&*props.read().unwrap()) |
|
|
@ -304,6 +309,7 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
SwayrCommand::ExecuteSwayrCommand => { |
|
|
|
SwayrCommand::ExecuteSwayrCommand => { |
|
|
|
let mut cmds = vec![ |
|
|
|
let mut cmds = vec![ |
|
|
|
SwayrCommand::ExecuteSwaymsgCommand, |
|
|
|
SwayrCommand::ExecuteSwaymsgCommand, |
|
|
|
|
|
|
|
SwayrCommand::MoveFocusedToWorkspace, |
|
|
|
SwayrCommand::QuitWindow, |
|
|
|
SwayrCommand::QuitWindow, |
|
|
|
SwayrCommand::QuitWorkspaceOrWindow, |
|
|
|
SwayrCommand::QuitWorkspaceOrWindow, |
|
|
|
SwayrCommand::SwitchWindow, |
|
|
|
SwayrCommand::SwitchWindow, |
|
|
@ -413,6 +419,13 @@ lazy_static! { |
|
|
|
regex::Regex::new(r"^#*s:(.*)").unwrap(); |
|
|
|
regex::Regex::new(r"^#*s:(.*)").unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn chop_workspace_shortcut(input: &str) -> &str { |
|
|
|
|
|
|
|
match SPECIAL_WORKSPACE.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; |
|
|
@ -420,10 +433,9 @@ fn handle_non_matching_input(input: &str) { |
|
|
|
|
|
|
|
|
|
|
|
if let Some(c) = SPECIAL_SWAY.captures(input) { |
|
|
|
if let Some(c) = SPECIAL_SWAY.captures(input) { |
|
|
|
run_sway_command(&c[1].split_ascii_whitespace().collect::<Vec<&str>>()); |
|
|
|
run_sway_command(&c[1].split_ascii_whitespace().collect::<Vec<&str>>()); |
|
|
|
} else if let Some(c) = SPECIAL_WORKSPACE.captures(input) { |
|
|
|
|
|
|
|
create_workspace(&c[1]); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
create_workspace(input); |
|
|
|
let ws = chop_workspace_shortcut(input); |
|
|
|
|
|
|
|
create_workspace(ws); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -552,6 +564,35 @@ pub fn switch_workspace(extra_props: &HashMap<i64, con::ExtraProps>) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn move_focused_container_to_workspace( |
|
|
|
|
|
|
|
extra_props: &HashMap<i64, con::ExtraProps>, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
let root = get_tree(); |
|
|
|
|
|
|
|
let workspaces = con::get_workspaces(&root, false, extra_props); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let val = util::select_from_menu( |
|
|
|
|
|
|
|
"Move focused container to workspace", |
|
|
|
|
|
|
|
&workspaces, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
let ws_name = &match val { |
|
|
|
|
|
|
|
Ok(workspace) => String::from(workspace.get_name()), |
|
|
|
|
|
|
|
Err(input) => String::from(chop_workspace_shortcut(&input)), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if DIGIT_AND_NAME.is_match(ws_name) { |
|
|
|
|
|
|
|
run_sway_command(&[ |
|
|
|
|
|
|
|
"move", |
|
|
|
|
|
|
|
"container", |
|
|
|
|
|
|
|
"to", |
|
|
|
|
|
|
|
"workspace", |
|
|
|
|
|
|
|
"number", |
|
|
|
|
|
|
|
ws_name, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
run_sway_command(&["move", "container", "to", "workspace", ws_name]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn switch_workspace_or_window(extra_props: &HashMap<i64, con::ExtraProps>) { |
|
|
|
pub fn switch_workspace_or_window(extra_props: &HashMap<i64, con::ExtraProps>) { |
|
|
|
let root = get_tree(); |
|
|
|
let root = get_tree(); |
|
|
|
let workspaces = con::get_workspaces(&root, true, extra_props); |
|
|
|
let workspaces = con::get_workspaces(&root, true, extra_props); |
|
|
|