X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=osdd.c;fp=osdd.c;h=15836ea51b7d36377197c5a94fd307bdb16b64e1;hb=845e5d4b6ac0a561a0ee55f6a11bdb4380d4e014;hp=df7c05b85c9e60870f5728d5758a4001d4c7fd79;hpb=931b9474fd8bfdadabd91121a71573553458d163;p=osdd.git diff --git a/osdd.c b/osdd.c index df7c05b..15836ea 100644 --- a/osdd.c +++ b/osdd.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -31,17 +32,19 @@ static char *default_color = "green"; static char *default_outline_color = "black"; static int default_duration = 1000; static int default_min_duration = 1000; +static int debug_mode; -static const char short_opts[] = "c:d:f:l:m:o:"; +static const char short_opts[] = "c:d:Df:l:m:o:"; static const struct option long_opts[] = { { "color", required_argument, NULL, 'c' }, + { "debug", no_argument, NULL, 'D' }, { "duration", required_argument, NULL, 'd' }, { "font", required_argument, NULL, 'f' }, { "lines", required_argument, NULL, 'l' }, { "min-duration", required_argument, NULL, 'm' }, { "outline-color", required_argument, NULL, 'o' }, - { NULL, 0, NULL, 0 }, + { NULL, 0, NULL, 0 }, }; static void NONRET @@ -50,6 +53,7 @@ usage(void) fprintf(stderr, "Usage: osdd \n\n\ Options:\n\ -c, --color=\t\tDefault color (#rgb, #rrggbb or a name from rgb.txt)\n\ +-D, --debug\t\tDebugging mode (do not detach from the terminal)\n\ -d, --duration=\tDefault message duration in milliseconds\n\ -f, --font=\t\tFont to use for the OSD\n\ -l, --lines=\t\tNumber of lines of the OSD\n\ @@ -72,6 +76,9 @@ parse_opts(int argc, char **argv) case 'd': default_duration = atoi(optarg); break; + case 'D': + debug_mode = 1; + break; case 'f': font_name = optarg; break; @@ -235,6 +242,19 @@ main(int argc, char **argv) if (!pty) die("Cannot intern OSD_QUEUE atom"); + if (!debug_mode) + { + pid_t pid = fork(); + if (pid < 0) + { + fprintf(stderr, "batt: Cannot fork: %m\n"); + return 1; + } + if (pid > 0) + return 0; + setsid(); + } + XSelectInput(dpy, win, PropertyChangeMask); XDeleteProperty(dpy, win, pty); XFlush(dpy);