mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-30 14:12:21 +02:00
feat(wm): move/send container to ws by direction
This commit introduces two new commands which will allow the user to move or send the currently focused window to either the next or previous workspace depending on the cycle direction. re #297
This commit is contained in:
2
justfile
2
justfile
@@ -28,7 +28,7 @@ install:
|
||||
|
||||
run:
|
||||
just install-komorebic
|
||||
cargo +stable run --bin komorebi --locked
|
||||
cargo +stable run --bin komorebi --locked -- -a
|
||||
|
||||
warn $RUST_LOG="warn":
|
||||
just run
|
||||
|
||||
@@ -47,8 +47,10 @@ pub enum SocketMessage {
|
||||
CycleStack(CycleDirection),
|
||||
MoveContainerToMonitorNumber(usize),
|
||||
MoveContainerToWorkspaceNumber(usize),
|
||||
CycleMoveContainerToWorkspace(CycleDirection),
|
||||
SendContainerToMonitorNumber(usize),
|
||||
SendContainerToWorkspaceNumber(usize),
|
||||
CycleSendContainerToWorkspace(CycleDirection),
|
||||
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
||||
MoveWorkspaceToMonitorNumber(usize),
|
||||
Close,
|
||||
|
||||
@@ -265,12 +265,44 @@ impl WindowManager {
|
||||
SocketMessage::MoveContainerToWorkspaceNumber(workspace_idx) => {
|
||||
self.move_container_to_workspace(workspace_idx, true)?;
|
||||
}
|
||||
SocketMessage::CycleMoveContainerToWorkspace(direction) => {
|
||||
let focused_monitor = self
|
||||
.focused_monitor()
|
||||
.ok_or_else(|| anyhow!("there is no monitor"))?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_else(|| anyhow!("there must be at least one workspace"))?,
|
||||
);
|
||||
|
||||
self.move_container_to_workspace(workspace_idx, true)?;
|
||||
}
|
||||
SocketMessage::MoveContainerToMonitorNumber(monitor_idx) => {
|
||||
self.move_container_to_monitor(monitor_idx, None, true)?;
|
||||
}
|
||||
SocketMessage::SendContainerToWorkspaceNumber(workspace_idx) => {
|
||||
self.move_container_to_workspace(workspace_idx, false)?;
|
||||
}
|
||||
SocketMessage::CycleSendContainerToWorkspace(direction) => {
|
||||
let focused_monitor = self
|
||||
.focused_monitor()
|
||||
.ok_or_else(|| anyhow!("there is no monitor"))?;
|
||||
|
||||
let focused_workspace_idx = focused_monitor.focused_workspace_idx();
|
||||
let workspaces = focused_monitor.workspaces().len();
|
||||
|
||||
let workspace_idx = direction.next_idx(
|
||||
focused_workspace_idx,
|
||||
NonZeroUsize::new(workspaces)
|
||||
.ok_or_else(|| anyhow!("there must be at least one workspace"))?,
|
||||
);
|
||||
|
||||
self.move_container_to_workspace(workspace_idx, false)?;
|
||||
}
|
||||
SocketMessage::SendContainerToMonitorNumber(monitor_idx) => {
|
||||
self.move_container_to_monitor(monitor_idx, None, false)?;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ MoveToWorkspace(target) {
|
||||
RunWait, komorebic.exe move-to-workspace %target%, , Hide
|
||||
}
|
||||
|
||||
CycleMoveToWorkspace(cycle_direction) {
|
||||
RunWait, komorebic.exe cycle-move-to-workspace %cycle_direction%, , Hide
|
||||
}
|
||||
|
||||
SendToMonitor(target) {
|
||||
RunWait, komorebic.exe send-to-monitor %target%, , Hide
|
||||
}
|
||||
@@ -104,6 +108,10 @@ SendToWorkspace(target) {
|
||||
RunWait, komorebic.exe send-to-workspace %target%, , Hide
|
||||
}
|
||||
|
||||
CycleSendToWorkspace(cycle_direction) {
|
||||
RunWait, komorebic.exe cycle-send-to-workspace %cycle_direction%, , Hide
|
||||
}
|
||||
|
||||
SendToMonitorWorkspace(target_monitor, target_workspace) {
|
||||
RunWait, komorebic.exe send-to-monitor-workspace %target_monitor% %target_workspace%, , Hide
|
||||
}
|
||||
|
||||
@@ -112,6 +112,8 @@ gen_enum_subcommand_args! {
|
||||
Move: OperationDirection,
|
||||
CycleFocus: CycleDirection,
|
||||
CycleMove: CycleDirection,
|
||||
CycleMoveToWorkspace: CycleDirection,
|
||||
CycleSendToWorkspace: CycleDirection,
|
||||
CycleMonitor: CycleDirection,
|
||||
CycleWorkspace: CycleDirection,
|
||||
Stack: OperationDirection,
|
||||
@@ -576,12 +578,18 @@ enum SubCommand {
|
||||
/// Move the focused window to the specified workspace
|
||||
#[clap(arg_required_else_help = true)]
|
||||
MoveToWorkspace(MoveToWorkspace),
|
||||
/// Move the focused window to the workspace in the given cycle direction
|
||||
#[clap(arg_required_else_help = true)]
|
||||
CycleMoveToWorkspace(CycleMoveToWorkspace),
|
||||
/// Send the focused window to the specified monitor
|
||||
#[clap(arg_required_else_help = true)]
|
||||
SendToMonitor(SendToMonitor),
|
||||
/// Send the focused window to the specified workspace
|
||||
#[clap(arg_required_else_help = true)]
|
||||
SendToWorkspace(SendToWorkspace),
|
||||
/// Send the focused window to the workspace in the given cycle direction
|
||||
#[clap(arg_required_else_help = true)]
|
||||
CycleSendToWorkspace(CycleSendToWorkspace),
|
||||
/// Send the focused window to the specified monitor workspace
|
||||
#[clap(arg_required_else_help = true)]
|
||||
SendToMonitorWorkspace(SendToMonitorWorkspace),
|
||||
@@ -847,12 +855,22 @@ fn main() -> Result<()> {
|
||||
SubCommand::MoveToWorkspace(arg) => {
|
||||
send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
SubCommand::CycleMoveToWorkspace(arg) => {
|
||||
send_message(
|
||||
&SocketMessage::CycleMoveContainerToWorkspace(arg.cycle_direction).as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::SendToMonitor(arg) => {
|
||||
send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
SubCommand::SendToWorkspace(arg) => {
|
||||
send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
SubCommand::CycleSendToWorkspace(arg) => {
|
||||
send_message(
|
||||
&SocketMessage::CycleSendContainerToWorkspace(arg.cycle_direction).as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::SendToMonitorWorkspace(arg) => {
|
||||
send_message(
|
||||
&SocketMessage::SendContainerToMonitorWorkspaceNumber(
|
||||
|
||||
Reference in New Issue
Block a user