Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the "-d" option.

It provides the user the ability to set the clock redraw frequency at
runtime.
  • Loading branch information...
commit a82fd716905a69d632d7a6641745d43a89ecaa18 1 parent 55038fd
Guillaume B authored
Showing with 20 additions and 13 deletions.
  1. +19 −12 ttyclock.c
  2. +1 −1  ttyclock.h
View
31 ttyclock.c
@@ -323,7 +323,7 @@ key_event(void)
{
int i, c;
- struct timespec length = { 0, UPDATETIME };
+ struct timespec length = { 0, ttyclock->option.delay };
switch(c = wgetch(stdscr))
{
@@ -417,23 +417,26 @@ main(int argc, char **argv)
strncpy(ttyclock->option.format, "%d/%m/%Y", 100);
/* Default color */
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)
{
case 'h':
default:
- printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n"
- " -s Show seconds \n"
- " -c Set the clock at the center of the terminal \n"
- " -C [0-7] Set the clock color \n"
- " -t Set the hour in 12h format \n"
- " -r Do rebound the clock \n"
- " -f format Set the date format \n"
- " -v Show tty-clock version \n"
- " -i Show some info about tty-clock \n"
- " -h Show this page \n");
+ printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n"
+ " -s Show seconds \n"
+ " -c Set the clock at the center of the terminal \n"
+ " -C [0-7] Set the clock color \n"
+ " -t Set the hour in 12h format \n"
+ " -r Do rebound the clock \n"
+ " -f format Set the date format \n"
+ " -v Show tty-clock version \n"
+ " -i Show some info about tty-clock \n"
+ " -h Show this page \n"
+ " -d delay Set the delay between two redraws of the clock \n");
free(ttyclock);
exit(EXIT_SUCCESS);
break;
@@ -468,6 +471,10 @@ main(int argc, char **argv)
case 'f':
strncpy(ttyclock->option.format, optarg, 100);
break;
+ case 'd':
+ if(atol(optarg) >= 0 && atol(optarg) < 1000000000)
+ ttyclock->option.delay = atol(optarg);
+ break;
}
}
View
2  ttyclock.h
@@ -45,7 +45,6 @@
#define NORMFRAMEW 35
#define SECFRAMEW 54
#define DATEWINH 3
-#define UPDATETIME 40000000
#define AMSIGN " [AM]"
#define PMSIGN " [PM]"
@@ -67,6 +66,7 @@ typedef struct
Bool rebound;
char *format;
int color;
+ long delay;
} option;
/* Clock geometry */
Please sign in to comment.
Something went wrong with that request. Please try again.