示例#1
0
static gboolean
new_osd(xosd **_osd, guint lines)
{
	xosd *osd = *_osd;

	if(osd) {
		if(xosd_get_number_lines(osd) == lines)
			return TRUE;

		xosd_destroy(osd);
	}

	if(lines <= 0) {
		osd = NULL;
		return FALSE;
	}

	osd = xosd_create(lines);

	xosd_set_pos(osd, XOSD_bottom);
	xosd_set_vertical_offset(osd, 16);
	xosd_set_align(osd, XOSD_center);
	xosd_set_horizontal_offset(osd, 0);

	xosd_set_font(osd, XOSD_FONT);
	xosd_set_outline_offset(osd, 1);
	xosd_set_outline_colour(osd, XOSD_OUTLINE_COLOR);
	xosd_set_shadow_offset(osd, 2);
	xosd_set_colour(osd, XOSD_COLOR);

	*_osd = osd;

	return TRUE;
}
示例#2
0
文件: first.c 项目: broli/tests
int main (int argc, char *argv[])
{
  xosd *osd;
  setlocale(LC_ALL, "");
  osd = xosd_create (2);
  if (osd == NULL)
    {
      perror ("Could not create \"osd\"");
      exit (1);
    }
  xosd_set_font (osd, "-*-verdana-*-*-*-*-17-*-*-*-*-*-*-*");  
  xosd_display (osd, 0, XOSD_string, "verdana 17-----------------------------------------------------------------------");
  sleep (2);
  /* el segundo*/
  xosd_set_shadow_offset (osd, 4);
  xosd_set_font (osd, "-*-terminus-*-*-*-*-20-*-*-*-*-*-*-*");
  xosd_set_colour (osd, "white");
  xosd_set_pos (osd, XOSD_bottom);
  xosd_set_align (osd, XOSD_center);
  xosd_set_vertical_offset (osd, 48);
  xosd_display (osd, 0, XOSD_string, "terminus 20 con shadow y otro color");
  sleep (8);
  xosd_destroy (osd);
  exit (0);
}
示例#3
0
int main (int argc, char *argv[])
{
  xosd *osd;
  int i;

  osd = xosd_create (10);

  xosd_set_font(osd, "fixed");
  xosd_set_colour(osd, "LawnGreen");
  xosd_set_timeout(osd, 3);
  xosd_set_shadow_offset(osd, 1);

  
  for(i = 0; i < 10; i ++) {
    xosd_display (osd, i, XOSD_printf, "Example XOSD output %d", i);
  }

  for(i = 0; i < 10; i ++) {
    sleep(1);
    printf(".");
    xosd_scroll(osd, 2);
  }
  



  xosd_wait_until_no_display(osd);

  xosd_destroy (osd);

  return 0;
}
示例#4
0
文件: osd_init.c 项目: tjouan/acpibat
void    osd_init(t_ab *ab) {
    ab->osd = xosd_create(1);

    xosd_set_font(ab->osd, "fixed");
    xosd_set_colour(ab->osd, "Green");
    xosd_set_pos(ab->osd, XOSD_bottom);
    xosd_set_horizontal_offset(ab->osd, OSD_X);
    xosd_set_shadow_offset(ab->osd, 1);
}
示例#5
0
int
main(void)
{
    int s_fd;
    struct sockaddr_un server;
    char msg[20];
    xosd *osd;

    if ((s_fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
        fprintf(stderr, "Couldn't create socket: %s\n", strerror(errno));
        return EXIT_FAILURE;
    }

    memset(&server, 0, sizeof(struct sockaddr_un));
    server.sun_family = AF_UNIX;
    strcpy(server.sun_path, VOLEVENTD_SOCKET);

    if (connect(s_fd, (struct sockaddr *) &server,
                sizeof(struct sockaddr_un)) < 0) {
        fprintf(stderr, "Couldn't connect to server: %s\n", strerror(errno));

        return EXIT_FAILURE;
    }
    memset(&msg, 0, sizeof(msg));

    /* set volume display options */
    osd = xosd_create(2);
    xosd_set_bar_length(osd, 30);
    xosd_set_pos(osd, XOSD_middle);
    xosd_set_align(osd, XOSD_center);

    while (read(s_fd, msg, 20)) {
        if (strncmp(msg, MSG_MUTE, 4) == 0) {
            volume_display(osd, parse_percent(msg, 5), !parse_mute(msg, 5));
        }
        else if (strncmp(msg, MSG_UNMUTE, 6) == 0) {
            volume_display(osd, parse_percent(msg, 7), !parse_mute(msg, 7));
        }
        else if (strncmp(msg, MSG_VOL_UP, 6) == 0) {
            volume_display(osd, parse_percent(msg, 7), !parse_mute(msg, 7));
        }
        else if (strncmp(msg, MSG_VOL_DOWN, 8) == 0) {
            volume_display(osd, parse_percent(msg, 9), !parse_mute(msg, 9));
        }
        memset(msg, 0, 20);
    }

    close(s_fd);

    return 0;
}
示例#6
0
文件: osd.c 项目: d-torrance/dockapps
int osd_init(char *progname, char *font, char *color,
	     int x, int y, int shadow, int timeout) {

#ifdef HAVE_XOSD
    /*
    osd = xosd_init(! font ? font : "fixed" ,
		    ! color ? color : "LawnGreen",
		    timeout,
		    XOSD_top,
		    x,
		    shadow,
		    1);
    if(!osd) {
    	fprintf(stderr, "%s: OSD error\n", progname);
	return 0;
    }
    */

    if (!(osd = xosd_create(1))) {
	fprintf(stderr, "%s: OSD error\n", progname);
	return 0;
    }

    if (font) {
	if (xosd_set_font(osd, font)) {
	    fprintf(stderr, "%s: OSD font init error\n", progname);
            xosd_set_font(osd, "fixed");
	}
    }
    else xosd_set_font(osd, "fixed");

    if (color) {
	if (xosd_set_colour(osd, color)) {
	    fprintf(stderr, "%s: OSD color init error\n", progname);
	    xosd_set_colour(osd, "LawnGreen");
	}
    }
    else xosd_set_colour(osd, "LawnGreen");

    xosd_set_vertical_offset(osd, y);
    xosd_set_horizontal_offset(osd, x);
    xosd_set_shadow_offset(osd, shadow);
    xosd_set_timeout(osd, timeout);

    return 1;
#else /* HAVE_XOSD */
    printf("wmradio: warning - compiled without osd\n");
    return 0;
#endif /* HAVE_XOSD */
}
示例#7
0
xosd *
configure_osd(int lines)
{
  xosd *osd;
  osd = xosd_create (NKEYS);

  xosd_set_font(osd, SK_FONT);
  xosd_set_pos(osd, SK_POS);
  xosd_set_align(osd, SK_ALIGN);
  xosd_set_colour(osd, SK_FG);
  xosd_set_outline_colour(osd, SK_OUTLINE);
  xosd_set_outline_offset(osd, SK_OFFSET);
  xosd_set_shadow_colour(osd, SK_SHADOW);
  xosd_set_shadow_offset(osd, SK_SHOFFSET);
  xosd_set_timeout(osd, SK_TIMEOUT);

  return osd;
}
示例#8
0
/*****************************************************************************
 * Open: initialize and create stuff
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    intf_thread_t *p_intf = (intf_thread_t *)p_this;
    intf_sys_t *p_sys;
    xosd *p_osd;
    char *psz_font, *psz_colour;

    if( getenv( "DISPLAY" ) == NULL )
    {
        msg_Err( p_intf, "no display, please set the DISPLAY variable" );
        return VLC_EGENERIC;
    }

    /* Allocate instance and initialize some members */
    p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
    if( p_sys == NULL )
        return VLC_ENOMEM;

    /* Initialize library */
    psz_font = config_GetPsz( p_intf, "xosd-font" );
    psz_colour = config_GetPsz( p_intf, "xosd-colour" );

    p_osd = xosd_create( 1 );
    if( p_osd == NULL )
    {
        msg_Err( p_intf, "couldn't initialize libxosd" );
        free( psz_colour );
        free( psz_font );
        free( p_sys );
        return VLC_EGENERIC;
    }
    p_sys->p_osd = p_osd;

    /* Set user preferences */
    xosd_set_outline_colour( p_osd, "black" );
    xosd_set_font( p_osd, psz_font );
    xosd_set_colour( p_osd, psz_colour );
    xosd_set_timeout( p_osd, 3 );
    xosd_set_pos( p_osd, config_GetInt( p_intf, "xosd-position" ) ?
                  XOSD_bottom: XOSD_top );
    xosd_set_horizontal_offset( p_osd,
                                config_GetInt( p_intf, "xosd-text-offset" ) );
    xosd_set_vertical_offset( p_osd,
                              config_GetInt( p_intf, "xosd-text-offset" ) );
    xosd_set_shadow_offset( p_osd,
                            config_GetInt( p_intf, "xosd-shadow-offset" ));

    /* Initialize to NULL */
    xosd_display( p_osd, 0, XOSD_string, "XOSD interface initialized" );

    free( psz_colour );
    free( psz_font );

    // Initialize mutex and condition variable before adding the callbacks
    vlc_mutex_init( &p_sys->lock );
    vlc_cond_init( &p_sys->cond );
    // Add the callbacks
    playlist_t *p_playlist = pl_Hold( p_intf );
    var_AddCallback( p_playlist, "item-current", PlaylistNext, p_this );
    var_AddCallback( p_playlist, "item-change", PlaylistNext, p_this );
    pl_Release( p_intf );

    p_sys->b_need_update = true;
    p_intf->pf_run = Run;
    return VLC_SUCCESS;
}
示例#9
0
/*****************************************************************************
 * Open: initialize and create stuff
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    intf_thread_t *p_intf = (intf_thread_t *)p_this;
    xosd *p_osd;

    /* Allocate instance and initialize some members */
    p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
    if( p_intf->p_sys == NULL )
    {
        msg_Err( p_intf, "out of memory" );
        return VLC_ENOMEM;
    }

    if( getenv( "DISPLAY" ) == NULL )
    {
        msg_Err( p_intf, "no display, please set the DISPLAY variable" );
        return VLC_EGENERIC;
    }

    /* Initialize library */
#if defined(HAVE_XOSD_VERSION_0) || defined(HAVE_XOSD_VERSION_1)
    p_osd  = p_intf->p_sys->p_osd =
        xosd_init( config_GetPsz( p_intf, "xosd-font" ),
                   config_GetPsz( p_intf,"xosd-colour" ), 3,
                   XOSD_top, 0, 1 );
    if( p_intf->p_sys->p_osd == NULL )
    {
        msg_Err( p_intf, "couldn't initialize libxosd" );
        return VLC_EGENERIC;
    }
#else
    p_osd = p_intf->p_sys->p_osd = xosd_create( 1 );
    if( p_osd == NULL )
    {
        msg_Err( p_intf, "couldn't initialize libxosd" );
        return VLC_EGENERIC;
    }
    xosd_set_colour( p_osd, config_GetPsz( p_intf,"xosd-colour" ) );
    xosd_set_timeout( p_osd, 3 );
#endif


    playlist_t *p_playlist =
            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                           FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return VLC_EGENERIC;
    }

    var_AddCallback( p_playlist, "playlist-current", PlaylistNext, p_this );
    var_AddCallback( p_playlist, "item-change", PlaylistNext, p_this );

    vlc_object_release( p_playlist );

    /* Set user preferences */
    xosd_set_font( p_intf->p_sys->p_osd,
                    config_GetPsz( p_intf, "xosd-font" ) );
    xosd_set_outline_colour( p_intf->p_sys->p_osd,"black" );
#ifdef HAVE_XOSD_VERSION_2
    xosd_set_horizontal_offset( p_intf->p_sys->p_osd,
                    config_GetInt( p_intf, "xosd-text-offset" ) );
    xosd_set_vertical_offset( p_intf->p_sys->p_osd,
                    config_GetInt( p_intf, "xosd-text-offset" ) );
#else
    xosd_set_offset( p_intf->p_sys->p_osd,
                    config_GetInt( p_intf, "xosd-text-offset" ) );
#endif
    xosd_set_shadow_offset( p_intf->p_sys->p_osd,
                    config_GetInt( p_intf, "xosd-shadow-offset" ));
    xosd_set_pos( p_intf->p_sys->p_osd,
                    config_GetInt( p_intf, "xosd-position" ) ?
                                         XOSD_bottom: XOSD_top );

    /* Initialize to NULL */
    xosd_display( p_osd, 0, XOSD_string, "XOSD interface initialized" );

    p_intf->pf_run = Run;

    p_intf->p_sys->b_need_update = VLC_TRUE;

    return VLC_SUCCESS;
}
示例#10
0
/*================================control_sh() ============================= */
void *control_sh(void *arg)
{
    int a,i;
    char c;
    char command[BUFSIZ];
    char command_arg[BUFSIZ];
    
    char fifo_file[PATH_MAX +1];

    FILE *fp;
    char readbuf[BUFSIZ];

    sprintf(fifo_file, "%s.%d",OSD_FIFO_PATH, getuid());
    settings.displaying = 1;
    /* we open the osd*/
	settings.myosd = xosd_create (2);

	initialize_osd(&settings);
	load_basic_plugins();

    /* create the fifo file*/
	unlink(fifo_file);
	umask(0);
	mknod(fifo_file, S_IFIFO|0600, 0);
	    /*open and read the fifo*/
	while (settings.displaying) {
		fp = fopen(fifo_file, "r");
		/*Read the bufer and check that it's not a comment*/
		while(fgets(readbuf, BUFSIZ, fp)) {

		    if (readbuf[c]=='#') continue;

		    /*ignore spaces*/
		    for (i=0; i<BUFSIZ&&((c=readbuf[i])==' '||c=='\t'); i++);
		    /*get the command*/
		    for (a=0; (c=readbuf[i])!='\n'&&c!='('; a++,i++)
			command[a] = readbuf[i];
		    command[a] = '\0';
		    /*get the command's arguments*/
		    i ++;
		    for(a=0; (c=readbuf[i])!='\0'&&c!='\n'&&c!=')';a++,i++) {
			if (c=='\\') {
			    i++;
			    command_arg[a] = readbuf[i];
		        }
			else {
			    command_arg[a]=c;
			}
		    }
		    command_arg[a] = '\0';
		    /*execute the command from the fifo and close it*/
		    display_stuff(command, command_arg);
		}
		fclose(fp);
	}
	unlink(fifo_file);
	sprintf(fifo_file, "%s.pid", fifo_file);
	unlink(fifo_file);
	xosd_destroy(settings.myosd);
	exit(0);
}
示例#11
0
文件: sublim.c 项目: enkiv2/asublim
	--screen-height	Specify screen height\n\n";
int main(int argc, char** argv) {
	signal(SIGINT, intHandler);
	
	xosd *osd;

	Display* d=XOpenDisplay(":0");
	
	int screenCount = ScreenCount(d);
	fprintf(stderr, "\nNumber of screens: %d\n", screenCount);
	int i;
	for (i=0; i<screenCount ; i++) {
		fprintf(stderr, " %d: %dx%x\n", i, DisplayWidth(d, i), DisplayHeight(d, i));
	}	

	int timeout;
	char* color="LawnGreen";
	char* font="-*-fixed-*-*-*-*-15-140-*-*-*-*-*-*";
	FILE* input=stdin;
	int delayShowMax=10000;
	int delayShowMin=1000;
	int delayWordMax=50;
	int delayWordMin=10;

	int screenWidthOverride=0;
	int screenHeightOverride=0;

	int ret;
	while((ret=getopt_long(argc, argv, ASublimOptString, lopts, NULL)) != -1) {
		switch(ret) {
			case 'S':
				delayShowMax=atoi(optarg);
				break;
			case 's':
				delayShowMin=atoi(optarg);
				break;
			case 'D':
				delayWordMax=atoi(optarg);
				break;
			case 'd':
				delayWordMin=atoi(optarg);
				break;
			case 't':
				timeout=atoi(optarg);
				break;
			case 'f':
				font=strncpy(malloc(strlen(optarg)+1), optarg, strlen(optarg)+1);
				break;
			case 'c':
				color=malloc(strlen(optarg));
				color=strncpy(malloc(strlen(optarg)+1), optarg, strlen(optarg)+1);
				break;
			case 'F':
				input=fopen(optarg, "r");
				if(errno) {
					fprintf(stderr, "File error! Defaulting to stdin.\n");
					input=stdin;
				}
				break;
			case 'w':
				screenWidthOverride=atoi(optarg);
				break;
			case 'y':
				screenHeightOverride=atoi(optarg);
				break;
			case 'h':
			case '?':
				fprintf(stderr, "Usage: %s %s", argv[0], helpstr);
				exit(0);
				break;
		}
	}

	osd = xosd_create(1);
	if(xosd_set_font(osd, font)==-1) {
		fprintf(stderr, "Font not found\n");
		exit(1);
	}
	if(xosd_set_colour(osd, color)==-1) {
		fprintf(stderr, "Color set error\n");
		exit(1);
	}
	if(xosd_set_timeout(osd, timeout)==-1) {
		fprintf(stderr, "Timeout set error\n");
		exit(1);
	}

	xosd_set_shadow_offset(osd, 3);
	srand48(time(NULL));
	char* buf=calloc(1025, sizeof(char));

	int height=screenHeightOverride;
	int width=screenWidthOverride;
	ret=fscanf(input, "%1024s", buf);
	while(buf[0]!=EOF && ret>0) {
		int screen = lrand48() % screenCount;
		if (!(screenWidthOverride && screenHeightOverride)) {
			height=	DisplayHeight(d, screen);
			width=	DisplayWidth(d, screen);
		}
		xosd_set_vertical_offset(osd, lrand48()%height);
		xosd_set_horizontal_offset(osd, lrand48()%width);
		xosd_display(osd, screen, XOSD_string, buf);
		
		xosd_show(osd);
		usleep((unsigned int)((lrand48()%(delayShowMax-delayShowMin)))+delayShowMin);
		xosd_hide(osd);
		
		ret=fscanf(input, "%1024s", buf);
		usleep((unsigned int)((lrand48()%(delayWordMax-delayWordMin)))+delayWordMin);
	}
	
	xosd_wait_until_no_display(osd);
	xosd_destroy(osd);

	return 0;
}
示例#12
0
文件: xcid.c 项目: amigan/cidserv
int
main (int argc, char *argv[])
{
/*	if(argc < 2) {
		fprintf(stderr, "Usage: %s server-ip\n", argv[0]);
		exit(1);
	}
	servaddr = strdup(argv[1]); */
#ifdef USE_XOSD
	int ch;
  	xosd *osd;
	while ((ch = getopt(argc, argv, "f:t:o:c:sa:")) != -1) {
		switch(ch) {
			case 'f':
				XOSD_FONT = strdup(optarg);
				break;
			case 'a': /* align... tr == top right bl ==
				     bottomleft */
				if(strlen(optarg) != 2) {
					fprintf(stderr, "-a error\n");
					exit(-1);
				}
				if(*optarg == 'b')
					vert = 0;
				if(optarg[1] == 'l')
					horiz = 0;
				break;
			case 't':
				XOSD_TIMEOUT = atoi(optarg);
				if(XOSD_TIMEOUT < 1) XOSD_TIMEOUT = 
					DEF_XOSD_TIMEOUT;
				break;
			case 'o':
				XOSD_VOFFSET = atoi(optarg);
				break;
			case 'c':
				XOSD_COLOUR = strdup(optarg);
				break;
			case 's':
				test = 1;
				break;
			case '?':
			default:
				usage();
				exit(-1);
		}
	}
	argc -= optind;
	argv += optind;

	if(test) {
osd = xosd_create(2);
  xosd_set_font(osd, XOSD_FONT);
  xosd_set_colour(osd, XOSD_COLOUR);
  xosd_set_timeout(osd, XOSD_TIMEOUT);
  xosd_set_pos(osd, vert ? XOSD_top : XOSD_bottom);
  xosd_set_align(osd, horiz ? XOSD_right : XOSD_left);
  xosd_set_vertical_offset(osd, XOSD_VOFFSET);
  xosd_set_shadow_offset(osd, 1);
  xosd_display(osd, 0, XOSD_printf, "Welcome to xcid!");
  xosd_wait_until_no_display(osd);
  xosd_destroy(osd);
}

#endif
  start_netloop ();
#ifdef USE_XOSD
  free(XOSD_COLOUR);
  free(XOSD_FONT);
#endif
  return 0;
}