I want every n-th window appear on next empty workspace
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?
add a comment
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?
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();
Gain some understanding about IPC, and pick your favorite language that has a i3 IPC library listed here.
Asked: 2014-03-22 10:31:09 +0000
Seen: 235 times
Last updated: Mar 26 '14