【问题标题】:using wmctrl to close windows使用 wmctrl 关闭窗口
【发布时间】:2011-07-16 19:25:33
【问题描述】:

我可以使用wmctrl 关闭在 Ubuntu 上的 wine 中运行的窗口吗?

对于上下文:

$ 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

但没有任何效果。

【问题讨论】:

    标签: window wine


    【解决方案1】:

    我也有同样的问题,只是找到了怎么做!

    这是一个可以优雅地关闭所有 Google Chrome 窗口的单行代码:

    wmctrl -lix |grep 'Google-chrome'|cut -d ' ' -f 1 |xargs -i% wmctrl -i -c %
    

    说明:

    wmctrl -lix 列出所有窗口,包括它们的 Id 和 Class

    grep 'Google-chrome' grep 仅带有 Google-chrome 类的窗口(这很重要,因为当您使用带有应用程序/快捷方式选项的网站时,它会获得它自己的类,例如 'calendar.google.com.Google-chrome'

    cut -d ' ' -f 1 剪切输出以仅获取 IDs 列

    xargs -i% wmctrl -i -c % 使用 ID option -i 将每个 ID 传递给 wmctrl 并关闭 command -c

    注意: xargs 仅在我使用 -i 选项指定替换字符串时才有效。否则它只会作用于第一项。

    【讨论】:

      【解决方案2】:

      可能有点晚了,但现在第一次看到。 阅读 wmctrl 的信息,它说正确的语法是actions 之前的“选项”,-i 是一个选项,-c 是一个动作。试试wmctrl -i -c 0x04400009

      【讨论】:

        【解决方案3】:

        根据the man page,您应该首先使用选择选项选择窗口,例如-r-a,例如:

        $ wmctrl -l      
        0x01800006  0 hostname Terminal - byobu
        
        $ wmctrl -a Terminal
        

        这里确实选择了终端窗口(并且由于-a 而引发+焦点)。

        然后您可以使用调整大小/移动选项,例如-e gravity,X,Y,width,height

        至于你的问题,我刚刚测试了这个:

        $ wmctrl -l                              
        0x01800006  0 machine_hostname - byobu
        0x06800002  0 moe Microsoft Excel - Classeur1
        

        当我进入时,Excel(显然是在 Wine 中运行)优雅地关闭

        $ wmctrl -c Microsoft
        

        大量附加信息here

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-02-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-12-15
          • 1970-01-01
          相关资源
          最近更新 更多