Linux window class name

xdotool: what are «class» and «classname» for a window?

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 via xprop command. For instance, Chrome has

WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

These two are documented as:

  • A string that names the particular instance of the application to which the client that owns this window belongs. .
  • A string that names the general class of applications to which the client that owns this window belongs. Resources that are specified by class apply to all applications that have the same class name.

Thus, for example Hangouts extension for Chrome, has same class name, but different instance name:

$ xprop | grep 'CLASS' WM_CLASS(STRING) = "crx_nckgahadagoaajjgafhacjanaoiihapd", "Google-chrome" 

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, and class corresponds the second string. In my example with Chrome and Hangouts apps:

$ xdotool search -classname crx_nckgahadagoaajjgafhacjanaoiihapd 96469129 $ xdotool search -class Google-chrome 96469069 109051905 109051907 96468993 96469129 109051912 109051924 

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 calls check_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.

Solution 2:

A class would be that like urxvt which actually contains both urxvt and rxvt which is the unicode rxvt terminal. The classname breaks those up into the actual names. I will show an example below.

I have 4 rxvt terminal windows open.

terrance-Linux:~$ xdotool search -class rxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -class urxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -classname urxvt terrance-Linux:~$ xdotool search -classname rxvt 130023435 127926283 125829131 132120587 

Then when I launched a urxvt terminal this is what I got.

terrance-Linux:~$ xdotool search -classname urxvt 140509193 

Using the xprop application we can click on the windows and it will tell us the WM_CLASS(STRING) . The first is the classname and the second is the class .

Читайте также:  Libdbusmenu gtk3 4 astra linux

Running the command and clicking on a RXVT terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "rxvt", "URxvt" 

Same command clicking on a URXVT window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "urxvt", "URxvt" 

Same command again clicking on a Google Chrome browser:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

Clicking on a xfce4-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "xfce4-terminal", "Xfce4-terminal" 

Clicking on a gnome-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "gnome-terminal-server", "Gnome-terminal" 

Clicking on a Firefox window (which is different):

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "Navigator", "Firefox" 

Hope this helps spread some light on the differences.

Источник

xdotool: what are «class» and «classname» for a window?

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 via xprop command. For instance, Chrome has

WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

These two are documented as:

  • A string that names the particular instance of the application to which the client that owns this window belongs. .
  • A string that names the general class of applications to which the client that owns this window belongs. Resources that are specified by class apply to all applications that have the same class name.

Thus, for example Hangouts extension for Chrome, has same class name, but different instance name:

$ xprop | grep 'CLASS' WM_CLASS(STRING) = "crx_nckgahadagoaajjgafhacjanaoiihapd", "Google-chrome" 

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, and class corresponds the second string. In my example with Chrome and Hangouts apps:

$ xdotool search -classname crx_nckgahadagoaajjgafhacjanaoiihapd 96469129 $ xdotool search -class Google-chrome 96469069 109051905 109051907 96468993 96469129 109051912 109051924 

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).

Читайте также:  Linux for android x86

This gets passed to xdo_search_windows function defined in xdo_search.c , which in turn calls check_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.

A class would be that like urxvt which actually contains both urxvt and rxvt which is the unicode rxvt terminal. The classname breaks those up into the actual names. I will show an example below.

I have 4 rxvt terminal windows open.

terrance-Linux:~$ xdotool search -class rxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -class urxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -classname urxvt terrance-Linux:~$ xdotool search -classname rxvt 130023435 127926283 125829131 132120587 

Then when I launched a urxvt terminal this is what I got.

terrance-Linux:~$ xdotool search -classname urxvt 140509193 

Using the xprop application we can click on the windows and it will tell us the WM_CLASS(STRING) . The first is the classname and the second is the class .

Running the command and clicking on a RXVT terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "rxvt", "URxvt" 

Same command clicking on a URXVT window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "urxvt", "URxvt" 

Same command again clicking on a Google Chrome browser:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

Clicking on a xfce4-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "xfce4-terminal", "Xfce4-terminal" 

Clicking on a gnome-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "gnome-terminal-server", "Gnome-terminal" 

Clicking on a Firefox window (which is different):

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "Navigator", "Firefox" 

Hope this helps spread some light on the differences.

Источник

xdotool: what are «class» and «classname» for a window?

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 via xprop command. For instance, Chrome has

WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

These two are documented as:

  • A string that names the particular instance of the application to which the client that owns this window belongs. .
  • A string that names the general class of applications to which the client that owns this window belongs. Resources that are specified by class apply to all applications that have the same class name.

Thus, for example Hangouts extension for Chrome, has same class name, but different instance name:

$ xprop | grep 'CLASS' WM_CLASS(STRING) = "crx_nckgahadagoaajjgafhacjanaoiihapd", "Google-chrome" 

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.

Читайте также:  Format in linux ext3

In particular for xdotool , classname corresponds with the first string, and class corresponds the second string. In my example with Chrome and Hangouts apps:

$ xdotool search -classname crx_nckgahadagoaajjgafhacjanaoiihapd 96469129 $ xdotool search -class Google-chrome 96469069 109051905 109051907 96468993 96469129 109051912 109051924 

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 calls check_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.

A class would be that like urxvt which actually contains both urxvt and rxvt which is the unicode rxvt terminal. The classname breaks those up into the actual names. I will show an example below.

I have 4 rxvt terminal windows open.

terrance-Linux:~$ xdotool search -class rxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -class urxvt 130023435 127926283 125829131 132120587 terrance-Linux:~$ xdotool search -classname urxvt terrance-Linux:~$ xdotool search -classname rxvt 130023435 127926283 125829131 132120587 

Then when I launched a urxvt terminal this is what I got.

terrance-Linux:~$ xdotool search -classname urxvt 140509193 

Using the xprop application we can click on the windows and it will tell us the WM_CLASS(STRING) . The first is the classname and the second is the class .

Running the command and clicking on a RXVT terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "rxvt", "URxvt" 

Same command clicking on a URXVT window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "urxvt", "URxvt" 

Same command again clicking on a Google Chrome browser:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "google-chrome", "Google-chrome" 

Clicking on a xfce4-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "xfce4-terminal", "Xfce4-terminal" 

Clicking on a gnome-terminal window:

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "gnome-terminal-server", "Gnome-terminal" 

Clicking on a Firefox window (which is different):

terrance-Linux:~$ xprop | grep WM_CLASS WM_CLASS(STRING) = "Navigator", "Firefox" 

Hope this helps spread some light on the differences.

Источник

Оцените статью
Adblock
detector