obxprop: Add ability to limit listing to given properties
This commit is contained in:
parent
2b0dfb81cf
commit
54c841f7b5
1 changed files with 27 additions and 6 deletions
|
@ -12,7 +12,7 @@ gint fail(const gchar *s) {
|
||||||
else
|
else
|
||||||
fprintf
|
fprintf
|
||||||
(stderr,
|
(stderr,
|
||||||
"Usage: obxprop [OPTIONS]\n\n"
|
"Usage: obxprop [OPTIONS] [--] [PROPERTIES ...]\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --help Display this help and exit\n"
|
" --help Display this help and exit\n"
|
||||||
" --display DISPLAY Connect to this X display\n"
|
" --display DISPLAY Connect to this X display\n"
|
||||||
|
@ -227,7 +227,7 @@ gboolean read_prop(Display *d, Window w, Atom prop, const gchar **type, gchar **
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_properties(Display *d, Window w)
|
void show_properties(Display *d, Window w, int argc, char **argv)
|
||||||
{
|
{
|
||||||
Atom* props;
|
Atom* props;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
@ -241,6 +241,18 @@ void show_properties(Display *d, Window w)
|
||||||
name = XGetAtomName(d, props[i]);
|
name = XGetAtomName(d, props[i]);
|
||||||
|
|
||||||
if (read_prop(d, w, props[i], &type, &val)) {
|
if (read_prop(d, w, props[i], &type, &val)) {
|
||||||
|
int found = 1;
|
||||||
|
if (argc) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
found = 0;
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
if (!strcmp(name, argv[i])) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
g_print("%s(%s) = %s\n", name, type, val);
|
g_print("%s(%s) = %s\n", name, type, val);
|
||||||
g_free(val);
|
g_free(val);
|
||||||
}
|
}
|
||||||
|
@ -283,6 +295,14 @@ int main(int argc, char **argv)
|
||||||
return fail(0);
|
return fail(0);
|
||||||
dname = argv[i];
|
dname = argv[i];
|
||||||
}
|
}
|
||||||
|
else if (*argv[i] != '-')
|
||||||
|
break;
|
||||||
|
else if (!strcmp(argv[i], "--")) {
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return fail(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = XOpenDisplay(dname);
|
d = XOpenDisplay(dname);
|
||||||
|
@ -295,12 +315,13 @@ int main(int argc, char **argv)
|
||||||
userid = RootWindow(d, DefaultScreen(d));
|
userid = RootWindow(d, DefaultScreen(d));
|
||||||
|
|
||||||
if (userid == None) {
|
if (userid == None) {
|
||||||
i = XGrabPointer(d, RootWindow(d, DefaultScreen(d)),
|
int j;
|
||||||
|
j = XGrabPointer(d, RootWindow(d, DefaultScreen(d)),
|
||||||
False, ButtonPressMask,
|
False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeAsync,
|
GrabModeAsync, GrabModeAsync,
|
||||||
None, XCreateFontCursor(d, XC_crosshair),
|
None, XCreateFontCursor(d, XC_crosshair),
|
||||||
CurrentTime);
|
CurrentTime);
|
||||||
if (i != GrabSuccess)
|
if (j != GrabSuccess)
|
||||||
return fail("Unable to grab the pointer device");
|
return fail("Unable to grab the pointer device");
|
||||||
while (1) {
|
while (1) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
@ -319,7 +340,7 @@ int main(int argc, char **argv)
|
||||||
if (id == None)
|
if (id == None)
|
||||||
return fail("Unable to find window with the requested ID");
|
return fail("Unable to find window with the requested ID");
|
||||||
|
|
||||||
show_properties(d, id);
|
show_properties(d, id, argc - i, &argv[i]);
|
||||||
|
|
||||||
XCloseDisplay(d);
|
XCloseDisplay(d);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue