Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created July 19, 2011 16:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordansissel/1092909 to your computer and use it in GitHub Desktop.
Save jordansissel/1092909 to your computer and use it in GitHub Desktop.
libxdo and WM_CLASS
% ./a.out $WINDOWID
Items: 22
Type: STRING
WM_CLASS[0]: terminator
WM_CLASS[1]: Terminator
#include <xdo.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
Window id;
xdo_t *xdo = xdo_new(NULL);
char *prop;
long nitems;
Atom type;
int size;
if (argc != 2) {
printf("Usage: %s <windowid>\n", argv[0]);
return 1;
}
id = atol(argv[1]);
prop = xdo_getwinprop(xdo, id, XInternAtom(xdo->xdpy, "WM_CLASS", False),
&nitems, &type, &size);
printf("Items: %d\n", nitems);
printf("Type: %s\n", XGetAtomName(xdo->xdpy, type));
int len;
int chars = nitems;
int index = 0;
while (chars > 0) {
printf("WM_CLASS[%d]: %s\n", index, prop);
len = strlen(prop) + 1; /* +1 for the null byte */
prop += len;
chars -= len;
index += 1;
}
return 0;
}
@trappedinspacetime
Copy link

xdo_getwinprop > xdo_get_window_property_by_atom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment