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

Automatically changing the layout after starting the second program on a workspace (similar to dwm)

asked 2013-04-05 09:40:42 +0000

Richard gravatar image

updated 2013-04-07 17:55:07 +0000

Hi all,

I am using the (horizontal) split layout by default. This means, if I start three programs, I see all of them side by side. Is it possible to change the layout for the second container on a workspace automatically from the horizontal split to some other layout?

For instance, after starting two programs it looks like this:

___________________
|_progr1_|_progr2_|
|        |        |
|________|________|

If I start now a third program, I would like to have it as a child of the second program-node, using a new layout (e.g. vertical spit or tabbed layout). So after the starting the third program, it should look like this:

___________________
|_progr1_|_progr2_|
|        |_progr3_|
|________|________|

Thank you very much!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2013-04-05 10:25:55 +0000

Hibou57 gravatar image

updated 2013-04-07 09:31:37 +0000

I tried to search, and believe the best way is to use i3wm IPC mechanism, as described in [sorry, can't post link] . You could subscribe to window events (described at the bottom of the page) and react accordingly, like changing the layout, which you could do sending a COMMAND message to i3wm.

I may try later to do it myself and will update this answer with a ready‑to‑use snippet if I do (will probably use Python).

Hint: you may also look at the question titled “How can I define my workspace on startup” (sorry, can't post a direct link).

Update

It's not mandatory to use the IPC API directly. There's a command line wrapper to send the same kind of messages: the i3-msg command.

edit flag offensive delete link more

Comments

1

Hi Hibou57, thanks for your reply, I have now an idea how it could work. However I didn't use the i3 IPC interface yet and I have just little time this weekend. I will try to write a script myself as soon as possible and post it to this question.

Richard gravatar imageRichard ( 2013-04-06 08:37:21 +0000 )edit
1

Richard, you may not need to use the IPC API directly. There's the `i3-msg` command which do the same. Do `man i3-msg` and you will see it covers the same type of message de IPC API do. `I3-msg` seems to be a command line wrapper for IPC.

Hibou57 gravatar imageHibou57 ( 2013-04-07 09:30:17 +0000 )edit
1

Hibou57, thanks, I already used i3-msg for changing the layout workspaces with a shortcut. But as far as I know, this doesn't allow me to change the layout depending on the number of programs running on a workspace, or is it possible to register to a window event using i3-msg or something similar?

Richard gravatar imageRichard ( 2013-04-07 09:47:21 +0000 )edit
1

No, I don't think so. To register to i3 events and react accordingly, I believe you need a daemon listening to i3 using its IPC. Or else, you may look at DWM, which behave as you expect, if I remember correctly (I tried DWM among others, before I decided to stick to i3).

Hibou57 gravatar imageHibou57 ( 2013-04-07 12:17:54 +0000 )edit
1

Yes I tried dwm and wmii before I finally got to i3. Probably this is why I miss this functionality. I am not sure anymore why I finally switched to i3 (I think dwm doesnt have a tabbed layout?) but now I like i3 very much. I will try first writing a daemon, before considering switching again. ;-)

Richard gravatar imageRichard ( 2013-04-07 16:38:14 +0000 )edit

Question Tools

Stats

Asked: 2013-04-05 09:40:42 +0000

Seen: 1,357 times

Last updated: Apr 07 '13