Added the "-d" option.

It provides the user the ability to set the clock redraw frequency at
runtime.
reverse-branch
Guillaume B 17 years ago
parent 55038fd7c1
commit a82fd71690
  1. 31
      ttyclock.c
  2. 2
      ttyclock.h

@ -323,7 +323,7 @@ key_event(void)
{ {
int i, c; int i, c;
struct timespec length = { 0, UPDATETIME }; struct timespec length = { 0, ttyclock->option.delay };
switch(c = wgetch(stdscr)) switch(c = wgetch(stdscr))
{ {
@ -417,23 +417,26 @@ main(int argc, char **argv)
strncpy(ttyclock->option.format, "%d/%m/%Y", 100); strncpy(ttyclock->option.format, "%d/%m/%Y", 100);
/* Default color */ /* Default color */
ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */ ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */
/* Default delay */
ttyclock->option.delay = 40000000; /* 25FPS */
while ((c = getopt(argc, argv, "tvsrcihf:C:")) != -1) while ((c = getopt(argc, argv, "tvsrcihfd:C:")) != -1)
{ {
switch(c) switch(c)
{ {
case 'h': case 'h':
default: default:
printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n" printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n"
" -s Show seconds \n" " -s Show seconds \n"
" -c Set the clock at the center of the terminal \n" " -c Set the clock at the center of the terminal \n"
" -C [0-7] Set the clock color \n" " -C [0-7] Set the clock color \n"
" -t Set the hour in 12h format \n" " -t Set the hour in 12h format \n"
" -r Do rebound the clock \n" " -r Do rebound the clock \n"
" -f format Set the date format \n" " -f format Set the date format \n"
" -v Show tty-clock version \n" " -v Show tty-clock version \n"
" -i Show some info about tty-clock \n" " -i Show some info about tty-clock \n"
" -h Show this page \n"); " -h Show this page \n"
" -d delay Set the delay between two redraws of the clock \n");
free(ttyclock); free(ttyclock);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
@ -468,6 +471,10 @@ main(int argc, char **argv)
case 'f': case 'f':
strncpy(ttyclock->option.format, optarg, 100); strncpy(ttyclock->option.format, optarg, 100);
break; break;
case 'd':
if(atol(optarg) >= 0 && atol(optarg) < 1000000000)
ttyclock->option.delay = atol(optarg);
break;
} }
} }

@ -45,7 +45,6 @@
#define NORMFRAMEW 35 #define NORMFRAMEW 35
#define SECFRAMEW 54 #define SECFRAMEW 54
#define DATEWINH 3 #define DATEWINH 3
#define UPDATETIME 40000000
#define AMSIGN " [AM]" #define AMSIGN " [AM]"
#define PMSIGN " [PM]" #define PMSIGN " [PM]"
@ -67,6 +66,7 @@ typedef struct
Bool rebound; Bool rebound;
char *format; char *format;
int color; int color;
long delay;
} option; } option;
/* Clock geometry */ /* Clock geometry */

Loading…
Cancel
Save