1 #include "xdo_cmd.h"
2
cmd_getwindowclassname(context_t * context)3 int cmd_getwindowclassname(context_t *context) {
4 char *cmd = context->argv[0];
5
6 int c;
7 static struct option longopts[] = {
8 { "help", no_argument, NULL, 'h' },
9 { 0, 0, 0, 0 },
10 };
11 static const char *usage =
12 "Usage: %s [window=%1]\n"
13 HELP_SEE_WINDOW_STACK;
14 int option_index;
15
16 while ((c = getopt_long_only(context->argc, context->argv, "+h",
17 longopts, &option_index)) != -1) {
18 switch (c) {
19 case 'h':
20 printf(usage, cmd);
21 consume_args(context, context->argc);
22 return EXIT_SUCCESS;
23 break;
24 default:
25 fprintf(stderr, usage, cmd);
26 return EXIT_FAILURE;
27 }
28 }
29
30 consume_args(context, optind);
31
32 const char *window_arg = "%1";
33 if (!window_get_arg(context, 0, 0, &window_arg)) {
34 fprintf(stderr, usage, cmd);
35 return EXIT_FAILURE;
36 }
37
38 unsigned char *name;
39
40 window_each(context, window_arg, {
41 xdo_get_window_classname(context->xdo, window, &name);
42 xdotool_output(context, "%s", name);
43 XFree(name);
44 }); /* window_each(...) */
45 return EXIT_SUCCESS;
46 }
47
48