views:

324

answers:

3

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

Thanx ...

A: 

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.

Dave
A: 

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.

Adam Goode
+2  A: 

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.

dtmilano