mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-02 14:24:21 +02:00
i3-companion: also offer possibility to move a window to a new workspace
This commit is contained in:
parent
334f77449c
commit
c5b2baca1e
2 changed files with 9 additions and 2 deletions
|
@ -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()
|
||||
|
|
1
config
1
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue