#include #include #include #include #include #define MAXTEXTLEN 30 #include void get_time(char * s_time) { time_t t; struct tm *tmp; t = time(NULL); tmp = localtime(&t); if (tmp == NULL) { perror("localtime"); exit(EXIT_FAILURE); } // if ( strftime (s_time, MAXTEXTLEN, "%l:%M:%S%p %a, %b %e", tmp) == 0 ) { if ( strftime (s_time, MAXTEXTLEN, "%l:%M%p %a, %b %e", tmp) == 0 ) { fprintf (stderr, "strftime returned 0"); exit (EXIT_FAILURE); } } int main (int argc, char *argv[]) { char *color = "#1e518a"; char *s_time = (char *) malloc(MAXTEXTLEN); char *old_time = (char *) malloc(MAXTEXTLEN); xosd *osd; if ( argc > 1 ) { color = argv[1]; } osd = xosd_create(1); xosd_set_font(osd, "-*-utopia-regular-r-*-*-*-180-*-*-*-135-*-*"); xosd_set_colour(osd, color); xosd_set_timeout(osd, 60); xosd_set_shadow_offset(osd, 1); xosd_set_align (osd, XOSD_right); xosd_set_vertical_offset (osd, 740); get_time(s_time); for (;;) { strncpy (old_time, s_time, MAXTEXTLEN); xosd_display (osd, 0, XOSD_string, s_time); while ( strcmp( old_time, s_time) == 0) { sleep(59); get_time (s_time); } xosd_wait_until_no_display(osd); } // xosd_wait_until_no_display(osd); xosd_destroy (osd); return 0; }