]> mj.ucw.cz Git - osdd.git/blob - osdc.c
A bit of debugging and also setting of default durations
[osdd.git] / osdc.c
1 /*
2  *      On-screen Display Client
3  *
4  *      (c) 2010 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <xosd.h>
11 #include <X11/Xlib.h>
12 #include <X11/Xatom.h>
13
14 #include "util.h"
15 #include "send.h"
16
17 static void NONRET
18 usage(void)
19 {
20   fprintf(stderr, "Usage: osdc [--<property>=<value> | <message>]*\n");
21   exit(1);
22 }
23
24 int main(int argc, char **argv)
25 {
26   struct osd_msg *m = osd_new_msg();
27
28   int more_opts = 1;
29   for (int i=1; i<argc; i++)
30     {
31       char *arg = argv[i];
32       if (more_opts && arg[0] == '-' && arg[1] == '-')
33         {
34           if (!arg[2])
35             more_opts = 0;
36           else
37             {
38               arg += 2;
39               if (!strcmp(arg, "help"))
40                 usage();
41               char *sep = strchr(arg, '=');
42               if (!sep)
43                 usage();
44               *sep++ = 0;
45               osd_add_line(m, arg, sep);
46             }
47         }
48       else
49         osd_add_line(m, NULL, arg);
50     }
51
52   osd_send(m);
53   return 0;
54 }