尝试:
wmctrl -r “window name(or any string in the title)” -t `wmctrl -d | grep “workspace name” | cut -d" " -f1`
让我解释一下:在wmctrl的帮助下显示
-r <WIN> -t <DESK> Move the window to the specified desktop.
<DESK> A desktop number. Desktops are counted from zero.
<WIN> This argument specifies the window. By default it's
interpreted as a string. The string is matched
against the window titles and the first matching
window is used. The matching isn't case sensitive
and the string may appear in any position
of the title.
The -i option may be used to interpret the argument
as a numerical window ID represented as a decimal
number. If it starts with "0x", then
it will be interpreted as a hexadecimal number.
wmctrl -d
可以列出所有工作区,我的计算机现在显示如下:
0-DG:1600x900 VP:不适用WA:0,0 1600x868代码
1 * DG:1600x900 VP:0,0 WA:0,0 1600x868播放
2-DG:1600x900 VP:N / A WA:0.011x868研究
*表示当前工作空间
顺便说一句,wmctrl -l
就是列出所有窗口(您已经知道),现在在我的计算机中它们是:
0x05400008 1个用户-LinuxMint终端
0x03a0008e 0用户-LinuxMint Mozilla Firefox
因为“ DESK”必须是数字,所以我用grep “workspace name” | cut -d" " -f1
它来获得它。
例如,如果我想将Firefox移至工作区“代码”,则可以使用:
wmctrl -r "firefox" -t 0
要么
wmctrl -r "moz" -t `wmctrl -d | grep "code" | cut -d" " -f1`
但
wmctrl -r -i 0x03a0008e -t `wmctrl -d | grep "code" | cut -d" " -f1`
只需为我工作一次,我不知道为什么!