The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Using IPC how can I move an app into a container?

asked 2015-04-19 19:13:02 +0000

AsaAyers gravatar image

I'm using Atom and I'd like to combine all Atom windows into a single tabbed container. I've been working a bit with i3-py. I have been able to find all Atom windows and have a target container, but move ... to container ... isn't a valid command.

Once I get my script working I can auto-merge windows with something like this.

for_window [class="Atom"] exec /home/asa/.i3/combine.py

Note: The Karma rules here really discourage new users. I can't post links and I can't vote. If I thought I could get help anywhere else I'd just leave.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2015-04-19 19:52:52 +0000

Airblader gravatar image

updated 2015-04-19 19:54:15 +0000

Airblader gravatar image

Great timing – just earlier today, a patch was merged that should help you. You can install i3 from source from the current next branch and then do this:

for_window [class="Atom"] move window to mark atom, layout tabbed

You just have to execute mark atom on any of Atom's windows (or whatever container you want them to be collected into).

edit flag offensive delete link more

Comments

I gave up on compiling from source years ago and much prefer to use a package manager. Are there any other options using `4.7.2-1` which is what is packaged in Ubuntu?

AsaAyers gravatar imageAsaAyers ( 2015-04-19 20:22:57 +0000 )edit

I'm sure it's *possible* with an IPC script, it's just more complicated. Maybe someone will help you write such a script, let's wait for more answers.

airblader gravatar imageairblader ( 2015-04-19 20:29:49 +0000 )edit
0

answered 2015-04-19 21:19:11 +0000

AsaAyers gravatar image

updated 2015-04-19 21:42:16 +0000

Here is my work in progress. I'm sure it's still buggy, but I think the concept is sound. If I open a 2nd window I don't know if it will combine it with the 1st or move my 1st window to where the new window is. Time will tell.

#!/usr/bin/env python3
import i3

atom = [w for w in i3.filter(nodes=[]) if w['name'][-4:] == 'Atom' ]

parents = [ i3.parent(a['id']) for a in atom ]

ids = [ p['id'] for p in parents ]
targetId = ids[0]
for id in ids:
    if ids.count(id) > ids.count(targetId):
        targetId = id

destContainer = [ p for p in parents if p['id'] == targetId ][0]

toMove = [ a for a in atom if i3.parent(a['id']) != destContainer]
pin = [ a for a in atom if i3.parent(a['id']) == destContainer][0]

if destContainer['layout'] != 'tabbed':
    print('focus', pin['window'])
    i3.focus(id=pin['window'])

    # If this contains any non atom windows, we need to split to create a
    # new container.
    foreignNodes = [ n for n in destContainer['nodes'] if atom.count(n) == 0 ]
    if len(foreignNodes) > 0:
        i3.split('v')
        destContainer = i3.parent(pin['id'])

    i3.layout('tabbed')

for m in toMove:
    print('focus', m['name'])
    i3.focus(id=m['window'])
    i3.move('scratchpad')

    print('focus', pin['window'])
    i3.focus(id=pin['window'])
    i3.scratchpad('show')

    print('focus', m['window'])
    i3.focus(id=m['window'])
    i3.floating('toggle')
edit flag offensive delete link more

Question Tools

Stats

Asked: 2015-04-19 19:13:02 +0000

Seen: 166 times

Last updated: Apr 19