mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
Add WorkspaceGroup{Next,Prev}Output command
This commit is contained in:
parent
90ec4a2566
commit
3ccf1d6eda
2 changed files with 48 additions and 0 deletions
|
|
@ -155,6 +155,11 @@ bindcode $mod+o exec "swaysome next-output"
|
||||||
# Move focused container to previous output
|
# Move focused container to previous output
|
||||||
bindcode $mod+Shift+o exec "swaysome prev-output"
|
bindcode $mod+Shift+o exec "swaysome prev-output"
|
||||||
|
|
||||||
|
# Move focused workspace group to next output
|
||||||
|
bindcode $mod+Alt+o exec "swaysome workspace-group-next-output"
|
||||||
|
# Move focused workspace group to previous output
|
||||||
|
bindcode $mod+Alt+Shift+o exec "swaysome workspace-group-prev-output"
|
||||||
|
|
||||||
# Init workspaces for every screen
|
# Init workspaces for every screen
|
||||||
exec "swaysome init 1"
|
exec "swaysome init 1"
|
||||||
```
|
```
|
||||||
|
|
|
||||||
43
src/main.rs
43
src/main.rs
|
|
@ -63,6 +63,12 @@ enum Command {
|
||||||
#[clap(about = "Move the focused container to the previous output")]
|
#[clap(about = "Move the focused container to the previous output")]
|
||||||
PrevOutput,
|
PrevOutput,
|
||||||
|
|
||||||
|
#[clap(about = "Move the focused workspace group to the next output")]
|
||||||
|
WorkspaceGroupNextOutput,
|
||||||
|
|
||||||
|
#[clap(about = "Move the focused workspace group to the previous output")]
|
||||||
|
WorkspaceGroupPrevOutput,
|
||||||
|
|
||||||
#[clap(about = "Move the focused container to the next group")]
|
#[clap(about = "Move the focused container to the next group")]
|
||||||
NextGroup,
|
NextGroup,
|
||||||
|
|
||||||
|
|
@ -602,6 +608,37 @@ impl SwaySome {
|
||||||
self.send_command(&cmd);
|
self.send_command(&cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn move_workspace_group_to_next_output(&self) {
|
||||||
|
self.move_workspace_group_to_next_or_prev_output(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_workspace_group_to_prev_output(&self) {
|
||||||
|
self.move_workspace_group_to_next_or_prev_output(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn move_workspace_group_to_next_or_prev_output(&self, go_to_prev: bool) {
|
||||||
|
let focused_output_index = self.get_current_output_index();
|
||||||
|
|
||||||
|
let target_output = if go_to_prev {
|
||||||
|
&self.outputs[(focused_output_index + self.outputs.len() - 1) % self.outputs.len()]
|
||||||
|
} else {
|
||||||
|
&self.outputs[(focused_output_index + 1) % self.outputs.len()]
|
||||||
|
};
|
||||||
|
let current_workspace = self.get_current_workspace_index();
|
||||||
|
let current_group_index = (current_workspace / MAX_GROUP_WS) as usize;
|
||||||
|
for workspace in self.get_workspaces() {
|
||||||
|
let ws_index = workspace.num / MAX_GROUP_WS;
|
||||||
|
if ws_index == current_group_index {
|
||||||
|
let cmd: String = format!("workspace number {}", workspace.num);
|
||||||
|
self.send_command(&cmd);
|
||||||
|
let cmd: String = format!("move workspace to {}", target_output.name);
|
||||||
|
self.send_command(&cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let cmd: String = format!("workspace number {}", current_workspace);
|
||||||
|
self.send_command(&cmd);
|
||||||
|
}
|
||||||
|
|
||||||
fn focus_container_to_next_group(&self) {
|
fn focus_container_to_next_group(&self) {
|
||||||
self.focus_container_to_next_or_prev_group(false);
|
self.focus_container_to_next_or_prev_group(false);
|
||||||
}
|
}
|
||||||
|
|
@ -686,6 +723,12 @@ fn main() {
|
||||||
Command::PrevOutput => {
|
Command::PrevOutput => {
|
||||||
swaysome.move_container_to_prev_output();
|
swaysome.move_container_to_prev_output();
|
||||||
}
|
}
|
||||||
|
Command::WorkspaceGroupNextOutput => {
|
||||||
|
swaysome.move_workspace_group_to_next_output();
|
||||||
|
}
|
||||||
|
Command::WorkspaceGroupPrevOutput => {
|
||||||
|
swaysome.move_workspace_group_to_prev_output();
|
||||||
|
}
|
||||||
Command::NextGroup => {
|
Command::NextGroup => {
|
||||||
swaysome.focus_container_to_next_group();
|
swaysome.focus_container_to_next_group();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue