デュアルディスプレイ構成があり、すべての新旧のアプリケーションを右側のプライマリディスプレイで起動する必要があります。ただし、フォーカス/マウスポインタがどこにあるかに関係なく、一部のアプリは2番目の画面で起動します。これは、上:左隅の0:0が2番目のモニターにあるためだと思います。そして、そのプライマリよりも大きい、これが原因である可能性がありますか?
セカンダリーは、私がkodiを実行しているテレビで、ディスプレイを選択する設定があります。
すべてのアプリの位置と表示を記憶し、2番目がオフになっている場合も注意するアプリがある可能性があります。つまり、モニターが再びオンになるまで位置を記憶します。以前のバージョンのubuntucompizでは、これを実行しますが、それ以上は実行しません。
更新:DEをシナモンに変更
承認された回答:
手を汚す準備をしてください
私たちがユーザーにお願いできると思うことの端にありますが、一方で、指示が明確な場合はどうでしょうか。では、ここに行きます…
新しいウィンドウを表示するモニターを設定するためのバックグラウンドプロセス
Valaスニペット
using Wnck;
using Gdk;
using Gtk;
// compile:
// valac --pkg gtk+-3.0 --pkg gio-2.0 --pkg libwnck-3.0 -X "-D WNCK_I_KNOW_THIS_IS_UNSTABLE" 'file.vala'
namespace move_newwins {
private int[] monitor_geo_x;
private int[] monitor_geo_y;
private int monitorindex;
private string currmon;
private void getwins() {
var dsp = Gdk.Display.get_default();
unowned Wnck.Screen scr = Wnck.Screen.get_default();
scr.force_update();
get_monitors(dsp);
scr.window_opened.connect(newwin);
}
private void newwin (Wnck.Window newwin) {
newwin.unmaximize();
int winx;
int winy;
int winwidth;
int winheight;
newwin.get_geometry(out winx, out winy, out winwidth, out winheight);
Wnck.WindowType type = newwin.get_window_type();
if (type == Wnck.WindowType.NORMAL) {
newwin.set_geometry(
Wnck.WindowGravity.NORTHWEST,
Wnck.WindowMoveResizeMask.X |
Wnck.WindowMoveResizeMask.Y |
Wnck.WindowMoveResizeMask.WIDTH |
Wnck.WindowMoveResizeMask.HEIGHT,
monitor_geo_x[monitorindex] + 100,
monitor_geo_y[monitorindex] + 100,
winwidth, winheight
);
}
}
private int get_stringindex (string s, string[] arr) {
for (int i=0; i < arr.length; i++) {
if(s == arr[i]) return i;
} return -1;
}
private void get_monitors(Gdk.Display dsp) {
int nmons = dsp.get_n_monitors();
string[] monitornames = {};
for (int i=0; i < nmons; i++) {
Gdk.Monitor newmon = dsp.get_monitor(i);
monitornames += newmon.get_model();
Rectangle geo = newmon.get_geometry();
monitor_geo_x += geo.x;
monitor_geo_y += geo.y;
monitorindex = get_stringindex(
currmon, monitornames
);
}
}
public static void main (string[] args) {
currmon = args[1];
Gtk.init(ref args);
getwins();
Gtk.main();
}
}
-
Valaスニペットをコンパイルする必要があります。そのためには、いくつかのものをインストールする必要があります:
sudo apt install valac libwnck-3-dev libgtk-3-dev
-
以下のスニペットをコピーして、
win_tomonitor.vala
として保存します -
次のコマンドでスニペットをコンパイルします:
valac --pkg gtk+-3.0 --pkg gio-2.0 --pkg libwnck-3.0 -X "-D WNCK_I_KNOW_THIS_IS_UNSTABLE" '/path/to/win_tomonitor.vala'
(wnck引数はばかげていますが、必要です)、実行可能ファイルは作業ディレクトリに作成されます。
- コマンド
xrandr
を実行して、プライマリモニターの名前を確認します ターミナルで。 -
ターゲットモニターを引数として実行可能ファイルを実行します。例:
/path/to/win_tomonitor HDMI-1
新しい(「通常の」)ウィンドウは、ターゲットモニターの左上から100px(x + y)に表示されます。
N.B。
これをスタートアップアイテムとして追加する場合は、実行する前に数秒の休憩を追加する必要がある場合があります。ログイン/起動時に問題が発生した場合は、お知らせください。
関連:Ubuntuの通知(アラート)サウンドを変更しますか?編集
編集されたバージョンの下(リクエストに応じて)。違い:
- このバージョンは、ターゲットモニターに既に存在するウィンドウでのアクションをスキップします。
-
このバージョンでは、除外された
WM_CLASS
を設定できます -es。 1つ以上のクラスを除外するには:後に引数を追加します 対象となるモニター引数。例:/path/to/win_tomonitor HDMI-1 Tilix Gedit
Tilixウィンドウとgeditウィンドウの両方を移動から除外します。
セットアップは最初のバージョンとまったく同じです。楽しんでください!
ウィンドウのWM_CLASSを確認する
- ターミナルウィンドウを開きます
- 「
xprop
」と入力します 、 Returnを押します - 対象のウィンドウ、
WM_CLASS
をクリックします ターミナルに表示されます
コード
using Wnck;
using Gdk;
using Gtk;
// compile:
// valac --pkg gtk+-3.0 --pkg gio-2.0 --pkg libwnck-3.0 -X "-D WNCK_I_KNOW_THIS_IS_UNSTABLE" 'file.vala'
namespace move_newwins {
private int[] monitor_geo_x;
private int[] monitor_geo_y;
private int monitorindex;
private string currmon;
Gdk.Display dsp;
string[] blacklist;
private void getwins() {
dsp = Gdk.Display.get_default();
unowned Wnck.Screen scr = Wnck.Screen.get_default();
scr.force_update();
get_monitors(dsp);
scr.window_opened.connect(newwin);
}
private void newwin (Wnck.Window newwin) {
newwin.unmaximize();
int winx;
int winy;
int winwidth;
int winheight;
newwin.get_geometry(out winx, out winy, out winwidth, out winheight);
string wins_monitor = dsp.get_monitor_at_point(winx, winy).get_model();
Wnck.WindowType type = newwin.get_window_type();
string wm_class = newwin.get_class_group_name();
bool blacklisted = get_stringindex(wm_class, blacklist) != -1;
if (
type == Wnck.WindowType.NORMAL &&
wins_monitor != currmon &&
!blacklisted
) {
newwin.set_geometry(
Wnck.WindowGravity.NORTHWEST,
Wnck.WindowMoveResizeMask.X |
Wnck.WindowMoveResizeMask.Y |
Wnck.WindowMoveResizeMask.WIDTH |
Wnck.WindowMoveResizeMask.HEIGHT,
monitor_geo_x[monitorindex] + 100,
monitor_geo_y[monitorindex] + 100,
winwidth, winheight
);
}
}
private int get_stringindex (string s, string[] arr) {
for (int i=0; i < arr.length; i++) {
if(s == arr[i]) return i;
} return -1;
}
private void get_monitors(Gdk.Display dsp) {
int nmons = dsp.get_n_monitors();
string[] monitornames = {};
for (int i=0; i < nmons; i++) {
Gdk.Monitor newmon = dsp.get_monitor(i);
monitornames += newmon.get_model();
Rectangle geo = newmon.get_geometry();
monitor_geo_x += geo.x;
monitor_geo_y += geo.y;
monitorindex = get_stringindex(
currmon, monitornames
);
}
}
public static void main (string[] args) {
currmon = args[1];
blacklist = args[1:args.length];
Gtk.init(ref args);
getwins();
Gtk.main();
}
}