Leo*_*Mew 12 window-manager multiple-monitors window cinnamon 18.04
我有双显示器配置,并希望所有新旧应用程序都在右侧的主显示器上启动。但是有些应用程序在第二个屏幕上启动,无论焦点/鼠标指针在哪里。我认为这是因为左上角 0:0 在第二台显示器上。它比主要的大,这可能是一个原因吗?
第二个是我运行 kodi 的电视,它有一个选择显示的设置。
可能有一些应用程序会记住每个应用程序的位置和显示,并且在关闭秒时也要小心 - 意味着记住位置直到显示器再次打开。在早期版本的 ubuntu compiz 中这样做,但没有更多。
更新:将 DE 更改为肉桂色
Jac*_*ijm 14
准备好弄脏你的手
在我觉得我们可以要求用户做的事情的边缘,但另一方面,当指示明确时,为什么不呢?所以我们开始...
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();
}
}
Run Code Online (Sandbox Code Playgroud)
需要编译 Vala 片段。为此,您需要安装一些东西:
sudo apt install valac libwnck-3-dev libgtk-3-dev
Run Code Online (Sandbox Code Playgroud)复制下面的代码片段,另存为 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'
Run Code Online (Sandbox Code Playgroud)
(我知道, wnck 参数很愚蠢,但需要),将在工作目录中生成一个可执行文件。
xrandr在终端中运行命令找出主监视器的名称。使用目标监视器作为参数运行可执行文件,例如
/path/to/win_tomonitor HDMI-1
Run Code Online (Sandbox Code Playgroud)新(“普通”)窗口将出现在目标监视器左上角 100px (x + y) 处。
将此添加为启动项时,您可能需要在运行它之前添加几秒钟的休息时间。如果您在登录/启动时遇到问题,请提及。
下面是编辑过的版本(应要求提供)。区别:
此版本允许设置排除的WM_CLASS-es。要排除一个或多个类:在目标监视器参数之后添加额外的参数。一个例子:
/path/to/win_tomonitor HDMI-1 Tilix Gedit
Run Code Online (Sandbox Code Playgroud)
排除 Tilix 和 gedit 窗口移动。
设置与第一个版本完全相同。玩得开心!
xprop, 按ReturnWM_CLASS出现在终端中sudo apt install valac libwnck-3-dev libgtk-3-dev
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2559 次 |
| 最近记录: |