From c5b2baca1eca3834c31e743bb9c1f081365afb16 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 5 Jul 2021 19:52:25 +0200 Subject: [PATCH] i3-companion: also offer possibility to move a window to a new workspace --- bin/i3-companion | 10 ++++++++-- config | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index 7be8f22..8e126a6 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -114,15 +114,21 @@ def workspace_rename(i3, event): def new_workspace(i3, event): """Create a new workspace.""" - if event.payload != "new-workspace": + if event.payload not in {"new-workspace", "move-to-new-workspace"}: return + if event.payload == "move-to-new-workspace": + current = i3.get_tree().find_focused() + workspace_nums = {w.num for w in i3.get_workspaces()} max_num = max(workspace_nums) available = (set(range(1, max_num + 2)) - workspace_nums).pop() logger.info(f'create new workspace number {available}') i3.command(f'workspace number "{available}"') + if event.payload == "move-to-new-workspace": + current.command(f'move container to workspace number "{available}"') + if __name__ == "__main__": options = parse_args() @@ -137,7 +143,7 @@ if __name__ == "__main__": Event.WINDOW_CLOSE}: i3.on(event, workspace_rename) - # Create a new workspace + # Create a new workspace or move to a new workspace i3.on(Event.TICK, new_workspace) i3.main() diff --git a/config b/config index d97574e..70f3459 100644 --- a/config +++ b/config @@ -135,6 +135,7 @@ bindsym $mod+Shift+8 move container to workspace number $ws8 bindsym $mod+Shift+9 move container to workspace number $ws9 bindsym $mod+Shift+0 move container to workspace number $ws10 bindsym $mod+Shift+o move workspace to output right +bindsym $mod+Shift+n exec i3-msg -t send_tick move-to-new-workspace # reload/restart bindsym $mod+Shift+c reload