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

I want every n-th window appear on next empty workspace

asked 2014-03-22 10:31:09 +0000

alikthename gravatar image

Let's say i want not to have more than 3 windows on a workspace. And if 4-th window appears it should open on next free workspace and focused. How to implement that?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2014-03-26 04:26:27 +0000

TonyC gravatar image

This is not difficult with the new ipc project. This uses the JavaScript version but the same API exists in many languages. The latest version of this script can be found here.

#!/usr/bin/env gjs

/*
   This example shows how to define a maximum number of windows per workspace.
   If a window is opened and the workspace has more than the defined number of
   maximum children containers, the new window will open on the next available
   workspace.

   https://faq.i3wm.org/question/3551/i-want-every-n-th-window-appear-on-next-empty-workspace/
*/

const i3ipc = imports.gi.i3ipc

let conn = new i3ipc.Connection;

const MAX_WINDOWS = 3;

conn.on('window::new', function(conn, e) {
    let win = conn.get_tree().find_focused();
    let ws = win.workspace();

    if (ws.nodes.length > MAX_WINDOWS) {
        win.command('move to workspace next, focus');
    }
});

conn.main();
edit flag offensive delete link more
0

answered 2014-03-22 11:31:57 +0000

joepd gravatar image

Gain some understanding about IPC, and pick your favorite language that has a i3 IPC library listed here.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-22 10:31:09 +0000

Seen: 235 times

Last updated: Mar 26 '14