In light of https://unix.stackexchange.com/a/254854/674 and https://unix.stackexchange.com/questions/458895/how-can-i-bring-a-background-gui-job-to-the-front-of-my-desktop, there is an example from manpage of xdotool
# Activate google-chrome when you move the mouse to the bottom-left corner:
xdotool behave_screen_edge bottom-left search --class google-chrome windowactivate
The manpage says
--class Match against the window class.
--classname Match against the window classname.
What are "class" and "classname"?
What possible values do they have?
How can I find out the class and classname of a window?
Thanks.
Under X11 windows have XWindowdAttributes structure and XClassHint structures properties from which applications get information about windows. Specifically the last one is responsible for the
WM_CLASS
property, two comma-separated strings, which can be seen easily viaxprop
command. For instance, Chrome hasThese two are documented as:
Thus, for example Hangouts extension for Chrome, has same class name, but different instance name:
This allows tools such as
xdotool
search all windows of particular application type, or specific window instance. For instance, this also can be useful property for something like docks that group windows under the same icon of an application.In particular for
xdotool
,classname
corresponds with the first string, andclass
corresponds the second string. In my example with Chrome and Hangouts apps:This also can be apparent from looking at the source code. Let's focus on classname for example. In the cmd_search.c we have a search struct built up, which has a search mask property(lines 171 to 173).
This gets passed to
xdo_search_windows
function defined in xdo_search.c , which in turn callscheck_window_match
, that in turn goes to _xdo_match_window_classname, which finally ends up retrieving both structures mentioned in the beginning of this answer with the standard Xlib functions XGetWindowAttributes and XGetClassHint.Side note: Gtk apps apparently always create a small parent window with a child window, which means you may get confusing results when searching for a specific window.