Skip to content
Snippets Groups Projects
Select Git revision
  • 7f62214e200912466f10da328ef8b00d916b771d
  • jk default protected
2 results

osdd.c

Blame
  • osdd.c 9.62 KiB
    /*
     *	On-screen Display Daemon
     *
     *	(c) 2010--2014 Martin Mares <mj@ucw.cz>
     */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <poll.h>
    #include <getopt.h>
    #include <locale.h>
    #include <X11/Xlib.h>
    #include <X11/Xatom.h>
    
    #undef DEBUG
    #include "util.h"
    #include "display.h"
    
    static struct osd_set osd;
    #define FOREACHOSD for(int i=0;i<osd.len;i++)
    
    static timestamp_t now;
    
    /*** Options ***/
    
    static char *font_name = "times-64:bold";
    static char *default_color = "green";
    static char *default_outline_color = "black";
    static int default_outline_width = 2;
    static int default_duration = 1000;
    static int default_min_duration = 250;
    static int default_log = 255;
    static int debug_mode;
    static int test_mode;
    static double line_spacing = 0.2;
    
    static const char short_opts[] = "c:d:Df:m:o:O:s:";
    
    enum long_opt {
      OPT_TEST = 256,
    };
    
    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' },
      { "min-duration",	required_argument,	NULL,	'm' },
      { "outline-color",	required_argument,	NULL,	'o' },
      { "outline-width",	required_argument,	NULL,	'O' },
      { "line-spacing",	required_argument,	NULL,	's' },
      { "log",		required_argument,	NULL,	'L' },
      { "test",		no_argument,		NULL,	OPT_TEST },	// Undocumented test mode
      { NULL,		0,			NULL,	0   },
    };
    
    static void NONRET
    usage(void)
    {
      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\
    -m, --min-duration=<ms>\tDefault minimum message duration in milliseconds\n\
    -o, --outline-color=<c>\tDefault outline color\n\
    -O, --outline-width=<n>\tDefault outline width (default=2)\n\