使用 wmctrl 关闭窗口
我可以使用 Ubuntu 上 wine 中运行的 wmctrl
关闭窗口吗?
对于上下文:
$ wmctrl -m
Name: compiz
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF
另外:
$ wmctrl -l
0x0240a3be -1 mjol N/A
0x02000003 0 mjol Top Expanded Edge Panel
0x0200004c 0 mjol Bottom Expanded Edge Panel
0x01e00024 0 mjol x-nautilus-desktop
0x04800253 0 mjol using wmctrl to close windows - Stack Overflow - Google Chrome
0x03c0c8c3 0 mjol Terminal
0x03c53f25 0 mjol Terminal
0x04400001 0 mjol Untitled - SketchUp
0x04400003 0 mjol Instructor
0x04400009 0 mjol SketchUp
我想关闭的窗口是最后一个:
0x04400009 0 mjol SketchUp
我已经尝试过以下操作:
$ wmctrl -c "SketchUp"
$ wmctrl -c 0x04400009
$ wmctrl -i 0x04400009
$ wmctrl -c -i 0x04400009
但没有任何效果。
Can I close a window using wmctrl
that is running in wine on Ubuntu?
For context:
$ wmctrl -m
Name: compiz
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF
Also:
$ wmctrl -l
0x0240a3be -1 mjol N/A
0x02000003 0 mjol Top Expanded Edge Panel
0x0200004c 0 mjol Bottom Expanded Edge Panel
0x01e00024 0 mjol x-nautilus-desktop
0x04800253 0 mjol using wmctrl to close windows - Stack Overflow - Google Chrome
0x03c0c8c3 0 mjol Terminal
0x03c53f25 0 mjol Terminal
0x04400001 0 mjol Untitled - SketchUp
0x04400003 0 mjol Instructor
0x04400009 0 mjol SketchUp
The window I want to close is the last one:
0x04400009 0 mjol SketchUp
I've tried the following:
$ wmctrl -c "SketchUp"
$ wmctrl -c 0x04400009
$ wmctrl -i 0x04400009
$ wmctrl -c -i 0x04400009
But nothing works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许有点晚了,但现在第一次看到。
阅读 wmctrl 的信息,它说正确的语法是
actions
之前的“options”,并且-i
是一个选项,-c
是一个选项。行动。尝试 wmctrl -i -c 0x04400009Maybe a little late, but first seen now.
Reading the info for wmctrl, it says that the correct syntax is 'options' before
actions
, and-i
is an option,-c
an action. Trywmctrl -i -c 0x04400009
我也有同样的问题,刚刚找到了如何做!
下面的一行代码将优雅地关闭所有 Google Chrome 窗口:
说明:
wmctrl -lix
列出所有窗口,包括其 ID 和类grep 'Google-chrome'
grep 仅具有 Google-chrome 类的窗口(这很重要,因为当您使用带有应用程序/快捷方式选项的网站时,它会获得自己的类,例如 'calendar.google.com.Google- chrome'cut -d ' ' -f 1
剪切输出以仅获取 ID 列xargs -i% wmctrl -i -c %
将每个 ID 传递给wmctrl
使用 ID 选项-i
并关闭命令-c
注意: xargs 仅在我使用
-i
选项指定替换字符串时才起作用,否则它只会作用于第一个项目。I was having the same question and just found how to do it!
Here's the one-liner that will gracefully close all Google Chrome windows:
Explanation:
wmctrl -lix
list all windows including their Id and Classgrep 'Google-chrome'
grep only windows with Google-chrome class (this is important because when you use a site with the app/shortcut option it gets it own class like 'calendar.google.com.Google-chrome'cut -d ' ' -f 1
cuts the output to get only the IDs columnxargs -i% wmctrl -i -c %
passes each ID to thewmctrl
using the ID option-i
and close command-c
Note: the xargs only worked when I used the
-i
option to specify replace-string. Otherwise it would only act on the first item.根据手册页,您应该选择< /strong> 窗口首先使用选择选项,例如
-r
和-a
,例如:这里确实选择了(并且由于
-a< /code>) 终端窗口。
然后你可以使用调整大小/移动选项,例如
-egravity,X,Y,width,height
至于你的问题,我刚刚测试了这个:
Excel(显然在 Wine 中运行)在以下情况下正常关闭我
在此处输入了大量附加信息。
According to the man page, you should select the window first using a select option, like
-r
and-a
, exemple :Here indeed selects (and raises + focus due to
-a
) the terminal window.Then you can use a resize / move option such as
-e gravity,X,Y,width,height
As for your question, I just tested this :
And Excel (obviously running in Wine) closed gracefully when I entered
Plenty of additional info here.