#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <inttypes.h>
#include <poll.h>
#include <getopt.h>
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
fprintf(stderr, "Usage: osdd <options>\n\n\
Options:\n\
-c, --color=<c>\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=<ms>\tDefault message duration in milliseconds\n\
-f, --font=<f>\t\tFont to use for the OSD\n\
-l, --lines=<n>\t\tNumber of lines of the OSD\n\
case 'd':
default_duration = atoi(optarg);
break;
+ case 'D':
+ debug_mode = 1;
+ break;
case 'f':
font_name = optarg;
break;
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);