mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-26 19:58:35 +02:00
i3-companion: add a command to open a new workspace
This is quite a generic idea: use tick to trigger some actions without spawning a whole Python process.
This commit is contained in:
parent
84db9ccb13
commit
f0c47af02e
2 changed files with 16 additions and 0 deletions
|
@ -112,6 +112,18 @@ def workspace_rename(i3, event):
|
|||
i3.command(';'.join(commands))
|
||||
|
||||
|
||||
def new_workspace(i3, event):
|
||||
"""Create a new workspace."""
|
||||
if event.payload != "new-workspace":
|
||||
return
|
||||
|
||||
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 __name__ == "__main__":
|
||||
options = parse_args()
|
||||
setup_logging(options)
|
||||
|
@ -125,6 +137,9 @@ if __name__ == "__main__":
|
|||
Event.WINDOW_CLOSE}:
|
||||
i3.on(event, workspace_rename)
|
||||
|
||||
# Create a new workspace
|
||||
i3.on(Event.TICK, new_workspace)
|
||||
|
||||
i3.main()
|
||||
except Exception as e:
|
||||
logger.exception("%s", e)
|
||||
|
|
1
config
1
config
|
@ -121,6 +121,7 @@ bindsym $mod+8 workspace number $ws8
|
|||
bindsym $mod+9 workspace number $ws9
|
||||
bindsym $mod+0 workspace number $ws10
|
||||
bindsym $mod+Tab workspace back_and_forth
|
||||
bindsym $mod+n exec i3-msg -t send_tick new-workspace
|
||||
|
||||
# move focused container to workspace
|
||||
bindsym $mod+Shift+1 move container to workspace number $ws1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue