mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-14 20:24:22 +02:00
i3-companion: make Alt-Tab local to a given output
This commit is contained in:
parent
7264c2ead5
commit
7283f44742
2 changed files with 36 additions and 1 deletions
|
@ -330,6 +330,41 @@ async def workspace_rename(i3, event):
|
|||
await i3.command(";".join(commands))
|
||||
|
||||
|
||||
@on(CommandEvent("previous-workspace"), I3Event.WORKSPACE_FOCUS)
|
||||
@static(history=collections.defaultdict(list))
|
||||
async def previous_workspace(i3, event):
|
||||
"""Go to previous workspace on the same output."""
|
||||
history = previous_workspace.history
|
||||
if isinstance(event, i3ipc.WorkspaceEvent) and event.old:
|
||||
data = event.old.ipc_data
|
||||
output, num = data["output"], data["num"]
|
||||
if history[output][-1:] != [num]:
|
||||
history[output].append(num)
|
||||
history[output] = history[output][-2:]
|
||||
logger.debug("on %s, history is %s", output, history[output])
|
||||
elif event == "previous-workspace":
|
||||
workspaces = await i3.get_workspaces()
|
||||
try:
|
||||
focused = [w for w in workspaces if w.focused][0]
|
||||
except IndexError:
|
||||
return
|
||||
output = focused.output
|
||||
while True:
|
||||
try:
|
||||
previous = history[output].pop()
|
||||
if [
|
||||
w
|
||||
for w in workspaces
|
||||
if w.num != focused.num and w.num == previous and w.output == output
|
||||
]:
|
||||
break
|
||||
except IndexError:
|
||||
logger.debug("no previous workspace on %s", output)
|
||||
return
|
||||
logger.debug("switching to workspace %d on %s", previous, output)
|
||||
await i3.command(f"workspace number {previous}")
|
||||
|
||||
|
||||
@on(CommandEvent("new-workspace"), CommandEvent("move-to-new-workspace"))
|
||||
async def new_workspace(i3, event):
|
||||
"""Create a new workspace and optionally move a window to it."""
|
||||
|
|
2
config
2
config
|
@ -112,7 +112,7 @@ bindsym $mod+7 workspace number $ws7
|
|||
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+Tab nop "previous-workspace"
|
||||
bindsym $mod+Ctrl+o focus output right
|
||||
bindsym $mod+n nop "new-workspace"
|
||||
focus_wrapping no
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue