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; }
--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; }
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; }