mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-20 17:15:41 +02:00
i3-companion: make i3-tabbed work by inhibiting exclusive workspaces
This commit is contained in:
parent
69e027f250
commit
f95d1e2b92
2 changed files with 34 additions and 6 deletions
|
@ -320,10 +320,23 @@ async def new_workspace(i3, event):
|
|||
await current.command(f"move container to workspace " f'number "{num}"')
|
||||
|
||||
|
||||
@on(I3Event.WINDOW_NEW)
|
||||
async def worksplace_exclusive(i3, event):
|
||||
@on(I3Event.WINDOW_NEW, CommandEvent("inhibit-exclusive"))
|
||||
@static(inhibited_by=False)
|
||||
async def workspace_exclusive(i3, event):
|
||||
"""Move new windows on a new workspace instead of sharing a workspace
|
||||
with an exclusive app."""
|
||||
if event == "inhibit-exclusive":
|
||||
logger.debug("inhibit exclusive workspace")
|
||||
me = object()
|
||||
workspace_exclusive.inhibited_by = me
|
||||
await asyncio.sleep(1)
|
||||
if workspace_exclusive.inhibited_by is me:
|
||||
logger.info("cancel exclusive workspace inhibition")
|
||||
workspace_exclusive.inhibited_by = None
|
||||
return
|
||||
if workspace_exclusive.inhibited_by:
|
||||
workspace_exclusive.inhibited_by = None
|
||||
return
|
||||
w = event.container
|
||||
|
||||
# Can the current window intrude the workspace?
|
||||
|
@ -905,6 +918,18 @@ async def main(options):
|
|||
|
||||
i3.on(I3Event.BINDING, binding_event)
|
||||
|
||||
# React to ticks
|
||||
async def tick_event(i3, event):
|
||||
"""Process tick events."""
|
||||
kind = event.payload.split(":")[0]
|
||||
for fn, events in on.functions.items():
|
||||
for e in events:
|
||||
if isinstance(e, CommandEvent) and e.name == kind:
|
||||
logger.debug("received command event %s for %s", event, fn)
|
||||
await fn(i3, event.payload)
|
||||
|
||||
i3.on(I3Event.TICK, tick_event)
|
||||
|
||||
# Listen to DBus events
|
||||
for fn, events in on.functions.items():
|
||||
for event in events:
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Splits the current terminal into a tab layout, runs a command, then restores the original layout.
|
||||
# Handy for opening images and videos "inside" a terminal.
|
||||
# Splits the current terminal into a tab layout, runs a command, then
|
||||
# restores the original layout. Handy for opening images and videos
|
||||
# "inside" a terminal.
|
||||
#
|
||||
# This effect is similar to dwm's window swallowing patch: https://www.youtube.com/watch?v=92uo5OBOKfY
|
||||
#
|
||||
# To be super minimal, configure i3 to use a 0px font size to hide the tab title bars. With the
|
||||
# unfortunate caveat that this will cause i3 error messages to become unreadable.
|
||||
# Stolen from https://github.com/aduros/dotfiles/blob/master/home/bin/i3-tabbed
|
||||
|
||||
from i3ipc import Connection
|
||||
import subprocess
|
||||
|
@ -28,6 +28,9 @@ elif layout == "splitv":
|
|||
orig.command("split h")
|
||||
orig.command("layout tabbed")
|
||||
|
||||
# Ensure we don't collide with exclusive app handling
|
||||
i3.send_tick("inhibit-exclusive")
|
||||
|
||||
try:
|
||||
# Run the given command
|
||||
code = subprocess.run(sys.argv[1:]).returncode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue