How to programmatically switch to a specific window in compiz?

本小妞迷上赌 提交于 2019-12-03 04:57:35

问题


Is there a command to tell compiz that we want to bring in front and set focus to a specific window? How should we identify the window in that command?

The reason behind this question is the following use-case:

Suppose we have a wiki to keep notes of anything interesting we find out. It would be very convenient to have a keyboard shortcut to bring the browser window with our Wiki page in front and start typing immediately then with another key combination switch to the application we were working before

I know that ALT + TAB switches between the last two used windows but cannot support more complex combinations of applications. E.g Browser+Eclipse+ Wiki

If there is a command like the one described, it is easy to add a shortcut to it from KDE or GNOME interface


回答1:


What you are looking for is wmctrl. For example, add a keyboard shortcut to invoke a command like

wmctrl -Fa 'Wiki - Google Chrome'

to raise and activate the window with that title.

There are different ways of selecting a window by title, id, etc. See man wmctrl. The list of windows can be obtained running

$ wmctrl -l

I haven't tried it with compiz but wmctrl should work for any EWMH compliant window manager.




回答2:


This worked for me with Compiz:

xdotool windowactivate `xdotool search --onlyvisible --class firefox`



回答3:


You'll want to send the _NET_ACTIVE_WINDOW client message to the root window. This will alert any compliant window manager (including Compiz) that you are requesting to make active a particular window.

See the EWMH spec, specifically the section on _NET_ACTIVE_WINDOW.

Note that depending on the window manager's configuration, it may refuse to honor your request, or give the user the chance to ignore it.




回答4:


I found this web page that has an example source program you could compile that will take bring an X window to the front.

The key is the X11 function XRaiseWindow.

I imagine it would be pretty easy to write a small program and either write a wrapper script or just make the program itself robust, and then set Compiz to attach this to a global keyboard shortcut.




回答5:


The Widget plugin could do what you describe.

  • Configure the Widget plugin to mark the desired windows as widgets (e.g. by matching on window title or role).
  • Configure the Window Rules plugin to make widget windows present on all workspaces (sticky) and to skip the taskbar.

See http://wiki.compiz.org/Plugins/Widget



来源:https://stackoverflow.com/questions/2000050/how-to-programmatically-switch-to-a-specific-window-in-compiz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!