mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-08 17:24:21 +02:00
i3-companion: rename duplicated workspaces
This happens easily when an output is left empty or on start.
This commit is contained in:
parent
1a30417043
commit
ce60feac8d
1 changed files with 17 additions and 0 deletions
|
@ -346,6 +346,23 @@ async def new_workspace(i3, event):
|
||||||
await current.command(f"move container to workspace " f'number "{num}"')
|
await current.command(f"move container to workspace " f'number "{num}"')
|
||||||
|
|
||||||
|
|
||||||
|
@on(I3Event.WORKSPACE_INIT)
|
||||||
|
@static(lock=None)
|
||||||
|
async def workspace_rename_duplicate(i3, event):
|
||||||
|
"""Rename a workspace when initialized empty with a duplicate number."""
|
||||||
|
# This will not be needed once https://github.com/i3/i3/pull/4252 is released.
|
||||||
|
if workspace_rename_duplicate.lock is None:
|
||||||
|
workspace_rename_duplicate.lock = asyncio.Lock()
|
||||||
|
async with workspace_rename_duplicate.lock:
|
||||||
|
workspace = event.current
|
||||||
|
workspaces = await i3.get_workspaces()
|
||||||
|
workspace_nums = {w.num for w in workspaces if workspace.id != w.ipc_data["id"]}
|
||||||
|
if workspace.num in workspace_nums:
|
||||||
|
max_num = max(workspace_nums)
|
||||||
|
available = (set(range(1, max_num + 2)) - workspace_nums).pop()
|
||||||
|
await i3.command(f"rename workspace {workspace.num} to {available}")
|
||||||
|
|
||||||
|
|
||||||
@on(I3Event.WINDOW_NEW, CommandEvent("inhibit-exclusive"))
|
@on(I3Event.WINDOW_NEW, CommandEvent("inhibit-exclusive"))
|
||||||
@static(inhibited_by=False)
|
@static(inhibited_by=False)
|
||||||
async def workspace_exclusive(i3, event):
|
async def workspace_exclusive(i3, event):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue