Commit 5228d457 authored by Giovanni Campagna's avatar Giovanni Campagna Committed by Florian Müllner

auto-move-windows: allow specifying a monitor index too

In addition to force windows on specific workspaces, it is useful to
assign them a specific monitor too.
Allow to do so by extending the configuration format.

As a small change, windows now get moved to the primary monitor if
they match a configured app. This is in line with the idea that
workspaces are only on the primary monitor.

Fixes #3
parent 724249dd
......@@ -68,11 +68,28 @@ const WindowMover = new Lang.Class({
let apps_to_space = spaces[j].split(":");
// Match application id
if (apps_to_space[0] == app_id) {
let workspace_num = parseInt(apps_to_space[1]) - 1;
let workspace_num, monitor_num;
if (apps_to_space.length == 2) {
workspace_num = parseInt(apps_to_space[1]);
monitor_num = Main.layoutManager.primaryMonitor;
} else {
workspace_num = apps_to_space[1] ? parseInt(apps_to_space[1]) :
global.screen.get_active_workspace_index();
monitor_num = parseInt(apps_to_space[2]);
}
if (workspace_num >= global.screen.n_workspaces)
this._ensureAtLeastWorkspaces(workspace_num, window);
if (workspace_num < 0)
workspace_num = global.screen.get_active_workspace_index();
if (monitor_num >= Main.layoutManager.monitors.length)
monitor_num = Main.layoutManager.monitors.length - 1;
if (monitor_num < 0)
monitor_num = 0;
window.move_to_monitor(monitor_num);
window.change_workspace_by_index(workspace_num, false);
}
}
......
......@@ -4,7 +4,7 @@
<!-- FIXME: should be a(su), when JS supports more of GVariant -->
<default>[ ]</default>
<summary>Application and workspace list</summary>
<description>A list of strings, each containing an application id (desktop file name), followed by a colon and the workspace number</description>
<description>A list of strings, each containing an application id (desktop file name), followed by a colon and the workspace number, optionally followed by another colon and a monitor number.</description>
</key>
</schema>
</schemalist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment