From 3594e6276b54f4508e969ec7b4a9c723ce6a2bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Wed, 5 May 2010 14:24:20 +0200 Subject: [PATCH 01/26] Add option (-b) to show border, default not shown --- README | 22 ++++++++++++---------- ttyclock.c | 16 ++++++++++++---- ttyclock.h | 1 + 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README b/README index e18294d..2942123 100755 --- a/README +++ b/README @@ -1,10 +1,12 @@ -usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] - -s Show seconds - -c Set the clock at the center of the terminal - -C [0-7] Set the clock color - -t Set the hour in 12h format - -r Do rebound the clock - -f format Set the date format - -v Show tty-clock version - -i Show some info about tty-clock - -h Show this page +usage : tty-clock [-sbctrvih] [-C [0-7]] [-f format] [-d delay] + -s Show seconds + -b Show box + -c Set the clock at the center of the terminal + -C [0-7] Set the clock color + -t Set the hour in 12h format + -r Do rebound the clock + -f format Set the date format + -v Show tty-clock version + -i Show some info about tty-clock + -h Show this page + -d delay Set the delay between two redraws of the clock diff --git a/ttyclock.c b/ttyclock.c index 8fa2306..5014803 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -86,14 +86,18 @@ init(void) ttyclock->geo.w, ttyclock->geo.x, ttyclock->geo.y); - box(ttyclock->framewin, 0, 0); + if(ttyclock->option.box) { + box(ttyclock->framewin, 0, 0); + } /* Create the date win */ ttyclock->datewin = newwin(DATEWINH, strlen(ttyclock->date.datestr) + 2, ttyclock->geo.x + ttyclock->geo.h - 1, ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1); - box(ttyclock->datewin, 0, 0); + if(ttyclock->option.box) { + box(ttyclock->datewin, 0, 0); + } clearok(ttyclock->datewin, True); set_center(ttyclock->option.center); @@ -420,14 +424,15 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfd:C:")) != -1) + while ((c = getopt(argc, argv, "tvsrcihfbd:C:")) != -1) { switch(c) { case 'h': default: - printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n" + printf("usage : tty-clock [-sbctrvih] [-C [0-7]] [-f format] [-d delay] \n" " -s Show seconds \n" + " -b Show box \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" @@ -475,6 +480,9 @@ main(int argc, char **argv) if(atol(optarg) >= 0 && atol(optarg) < 1000000000) ttyclock->option.delay = atol(optarg); break; + case 'b': + ttyclock->option.box = True; + break; } } diff --git a/ttyclock.h b/ttyclock.h index 911aa20..e136751 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -64,6 +64,7 @@ typedef struct Bool twelve; Bool center; Bool rebound; + Bool box; char *format; int color; long delay; From 8502f635db47715ae3f1c157debffbc3dc363b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Wed, 5 May 2010 15:55:34 +0200 Subject: [PATCH 02/26] Press 'b' to switch box on/off --- ttyclock.c | 35 +++++++++++++++++++++++++++++++++-- ttyclock.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ttyclock.c b/ttyclock.c index 5014803..237bd74 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -258,8 +258,10 @@ clock_move(int x, int y, int w, int h) ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1); wresize(ttyclock->datewin, DATEWINH, strlen(ttyclock->date.datestr) + 2); - box(ttyclock->framewin, 0, 0); - box(ttyclock->datewin, 0, 0); + if(ttyclock->option.box) { + box(ttyclock->framewin, 0, 0); + box(ttyclock->datewin, 0, 0); + } wrefresh(ttyclock->datewin); wrefresh(ttyclock->framewin); @@ -322,6 +324,29 @@ set_center(Bool b) return; } +void +set_box(Bool b) +{ + ttyclock->option.box = b; + + wbkgdset(ttyclock->framewin, COLOR_PAIR(0)); + wbkgdset(ttyclock->datewin, COLOR_PAIR(0)); + + if(ttyclock->option.box) { + wbkgdset(ttyclock->framewin, COLOR_PAIR(0)); + wbkgdset(ttyclock->datewin, COLOR_PAIR(0)); + box(ttyclock->framewin, 0, 0); + box(ttyclock->datewin, 0, 0); + } + else { + wborder(ttyclock->framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + wborder(ttyclock->datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + } + + wrefresh(ttyclock->datewin); + wrefresh(ttyclock->framewin); +} + void key_event(void) { @@ -392,6 +417,12 @@ key_event(void) if(ttyclock->option.rebound && ttyclock->option.center) ttyclock->option.center = False; break; + + case 'b': + case 'B': + set_box(!ttyclock->option.box); + break; + default: nanosleep(&length, NULL); for(i = 0; i < 8; ++i) diff --git a/ttyclock.h b/ttyclock.h index e136751..08c8a32 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -107,6 +107,7 @@ void draw_clock(void); void clock_move(int x, int y, int w, int h); void set_second(void); void set_center(Bool b); +void set_box(Bool b); void key_event(void); /* Global variable */ From ab96db2e4e160fdf83f8110f3b31e7c3e8e452e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Wed, 5 May 2010 16:07:26 +0200 Subject: [PATCH 03/26] Correct format specification bug --- ttyclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 237bd74..052922c 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -455,7 +455,7 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfbd:C:")) != -1) + while ((c = getopt(argc, argv, "tvsrcihbf:d:C:")) != -1) { switch(c) { From da6985db9d068edd628cdba73132e607cd951294 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 4 Nov 2010 10:37:18 +0100 Subject: [PATCH 04/26] Fixed segfault with now non-working -f option. The commit to add the -d option broke getopt for -f taking an argument. --- ttyclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 8fa2306..3a7122c 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -420,7 +420,7 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfd:C:")) != -1) + while ((c = getopt(argc, argv, "tvsrcihf:d:C:")) != -1) { switch(c) { From 4644b630643ba152467ddb97809461881102c8df Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 4 Nov 2010 10:41:53 +0100 Subject: [PATCH 05/26] Changed default date format. In order to avoid mixing up day and month its better to use %F (the ISO 8601 date format) to be more international understandable. --- ttyclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 3a7122c..19a9d27 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -414,7 +414,7 @@ main(int argc, char **argv) /* Date format */ ttyclock->option.format = malloc(sizeof(char) * 100); /* Default date format */ - strncpy(ttyclock->option.format, "%d/%m/%Y", 100); + strncpy(ttyclock->option.format, "%F", 100); /* Default color */ ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */ /* Default delay */ From df64a7fbb2fe270c98426f8f4556e5a14bd6fa30 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 4 Nov 2010 10:49:22 +0100 Subject: [PATCH 06/26] Added -d to program usage outout and to README. --- README | 3 ++- ttyclock.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README b/README index e18294d..62d1726 100755 --- a/README +++ b/README @@ -1,4 +1,4 @@ -usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] +usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] [-d delay] -s Show seconds -c Set the clock at the center of the terminal -C [0-7] Set the clock color @@ -8,3 +8,4 @@ usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] -v Show tty-clock version -i Show some info about tty-clock -h Show this page + -d delay Set the delay between two redraws of the clock diff --git a/ttyclock.c b/ttyclock.c index 19a9d27..1a8daee 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -426,7 +426,7 @@ main(int argc, char **argv) { case 'h': default: - printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n" + printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] [-d delay] \n" " -s Show seconds \n" " -c Set the clock at the center of the terminal \n" " -C [0-7] Set the clock color \n" From 2f2aaa09a08611eda7ab41f2c60693440c6ae254 Mon Sep 17 00:00:00 2001 From: Skami18 Date: Sat, 28 May 2011 15:12:34 +0200 Subject: [PATCH 07/26] Added the screensaver mode --- README | 3 ++- ttyclock.c | 30 ++++++++++++++++++++++++++++-- ttyclock.h | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README b/README index e18294d..75307d5 100755 --- a/README +++ b/README @@ -1,5 +1,6 @@ -usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] +usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format] -s Show seconds + -S Screensaver mode -c Set the clock at the center of the terminal -C [0-7] Set the clock color -t Set the hour in 12h format diff --git a/ttyclock.c b/ttyclock.c index 8fa2306..fb49e8a 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -324,6 +324,28 @@ key_event(void) int i, c; struct timespec length = { 0, ttyclock->option.delay }; + + if (ttyclock->option.screensaver) + { + c = wgetch(stdscr); + if(c != ERR) + { + ttyclock->running = False; + } + else + { + nanosleep(&length, NULL); + for(i = 0; i < 8; ++i) + if(c == (i + '0')) + { + ttyclock->option.color = i; + init_pair(1, ttyclock->bg, i); + init_pair(2, i, ttyclock->bg); + } + } + return; + } + switch(c = wgetch(stdscr)) { @@ -420,14 +442,15 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfd:C:")) != -1) + while ((c = getopt(argc, argv, "tvsSrcihfd:C:")) != -1) { switch(c) { case 'h': default: - printf("usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] \n" + printf("usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format] \n" " -s Show seconds \n" + " -S Screensaver mode \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" @@ -455,6 +478,9 @@ main(int argc, char **argv) case 's': ttyclock->option.second = True; break; + case 'S': + ttyclock->option.screensaver = True; + break; case 'c': ttyclock->option.center = True; break; diff --git a/ttyclock.h b/ttyclock.h index 911aa20..d464195 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -61,6 +61,7 @@ typedef struct struct { Bool second; + Bool screensaver; Bool twelve; Bool center; Bool rebound; From 39f9d8843a5ddb16f71db6a510edea05db3b6ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Sat, 16 Jul 2011 22:25:58 -0400 Subject: [PATCH 08/26] make clean succeed all the time --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6fff8be..bc7244e 100755 --- a/Makefile +++ b/Makefile @@ -31,6 +31,6 @@ uninstall : clean : @echo "cleaning ${BIN}" - @rm ${BIN} + @rm -f ${BIN} @echo "${BIN} cleaned" From e913062e82bdb113b761e6b97d5a7e09373a3d4f Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Mon, 15 Aug 2011 16:31:04 -0400 Subject: [PATCH 09/26] * Add manpage tty-clock.1 and modify Makefile accordingly * Also apply debian Makefile patch --- Makefile | 21 ++++++++++---- tty-clock.1 | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 tty-clock.1 diff --git a/Makefile b/Makefile index 6fff8be..0eac46d 100755 --- a/Makefile +++ b/Makefile @@ -5,7 +5,9 @@ SRC = ttyclock.c CC = cc BIN = tty-clock -INSTALLPATH = /usr/local/bin/ +PREFIX ?= /usr/local +INSTALLPATH = ${DESTDIR}${PREFIX}/bin +MANPATH = ${DESTDIR}${PREFIX}/share/man/man1 CFLAGS = -Wall -g LDFLAGS = -lncurses @@ -18,19 +20,26 @@ tty-clock : ${SRC} install : ${BIN} - @echo "installing binary file to ${INSTALLPATH}${BIN}" + @echo "installing binary file to ${INSTALLPATH}/${BIN}" + @mkdir -p ${INSTALLPATH} @cp ${BIN} ${INSTALLPATH} - @chmod 755 ${INSTALLPATH}${BIN} + @chmod 0755 ${INSTALLPATH}/${BIN} + @echo "installing manpage to ${MANPATH}/${BIN}.1" + @mkdir -p ${MANPATH} + @cp ${BIN}.1 ${MANPATH} + @chmod 0644 ${MANPATH}/${BIN}.1 @echo "installed" uninstall : - @echo "uninstalling binary file (${INSTALLPATH}${BIN})" - @rm -f ${INSTALLPATH}${BIN} + @echo "uninstalling binary file (${INSTALLPATH})" + @rm -f ${INSTALLPATH}/${BIN} + @echo "uninstalling manpage (${MANPATH})" + @rm -f ${MANPATH}/${BIN}.1 @echo "${BIN} uninstalled" clean : @echo "cleaning ${BIN}" - @rm ${BIN} + @rm -f ${BIN} @echo "${BIN} cleaned" diff --git a/tty-clock.1 b/tty-clock.1 new file mode 100644 index 0000000..86acab3 --- /dev/null +++ b/tty-clock.1 @@ -0,0 +1,81 @@ +.\" This manpage was written by Carla Valenti +.\" for tty-clock. In details the command line options displayed by +.\" tty-clock -h as well as the keyboard commands. +.TH "TTY-CLOCK" 1 "August 2011" "" "User Commands" +.SH NAME +.LP +tty-clock - a terminal digital clock +.SH SYNOPSIS +.LP +\fBtty\-clock [\-sbctrvih] [\-C [\fP\fI0\-7\fP\fB]] [\-f\fP \fIformat\fP\fB] [\-d \fIdelay\fP\fB]\fP +.SH DESCRIPTION +.LP +\fItty-clock\fP displays a simple digital clock on the terminal +.SH COMMANDS +.LP +\fItty-clock\fP accepts a number of runtime keyboard commands, upper and lower case characters are +treated identically. +.TP +K,J,H,L +vi-style movement commands to set the position of the displayed clock. +These commands have no effect when the \fBcentered\fP option is set. +.TP +S +Display seconds. +.TP +T +Switch time output to the 12-hour format. +.TP +C +Toggle the clock's position to \fBcentered\fP. +When set the movement commands are disabled. +.TP +R +Set the clock to \fBrebound\fP along the edges of the terminal. +.TP +Q +Quit. +.SH OPTIONS +.LP +.TP +\fB\-s\fR +Show seconds. +.TP +\fB\-b\fR +Show box. +.TP +\fB\-c\fR +Set the clock at the center of the terminal +.TP +\fB\-C\fR \fI[0\-7]\fP +Set the clock color. +.TP +\fB\-t\fR +Set the hour in 12h format. +.TP +\fB\-r\fR +Do rebound the clock. +.TP +\fB\-f\fR \fIformat\fP +Set the date format as described in \fBstrftime(3)\fP. +.TP +\fB\-v\fR +Show tty\-clock version. +.TP +\fB\-i\fR +Show some info about tty\-clock. +.TP +\fB\-h\fR +Show usage information. +.TP +\fB\-d\fR \fIdelay\fP +Set the delay between two redraws of the clock. +.SH "AUTHOR" +Written by Martin Duquesnoy . +.LP +manpage written by Carla Valenti . +.LP +Please report +.I tty-clock +bugs to +.B xorg62@gmail.com From 2b4bf01a283cc26c94ef7abe9207b23ad33fb7a3 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Mon, 15 Aug 2011 17:35:22 -0400 Subject: [PATCH 10/26] * Fix -f and avoid related SIGSEGV * Remove free'd pointer indirections and move cleanup code to own fuction. --- ttyclock.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ttyclock.c b/ttyclock.c index 8fa2306..f4d3ad3 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -131,6 +131,15 @@ signal_handler(int signal) return; } +void +cleanup(void) +{ + if (ttyclock && ttyclock->option.format) + free(ttyclock->option.format); + if (ttyclock) + free(ttyclock); +} + void update_hour(void) { @@ -420,7 +429,9 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfd:C:")) != -1) + atexit(cleanup); + + while ((c = getopt(argc, argv, "tvsrcihf:d:C:")) != -1) { switch(c) { @@ -437,19 +448,14 @@ main(int argc, char **argv) " -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; case 'i': puts("TTY-Clock 2 © by Martin Duquesnoy (xorg62@gmail.com)"); - free(ttyclock); - free(ttyclock->option.format); exit(EXIT_SUCCESS); break; case 'v': puts("TTY-Clock 2 © devel version"); - free(ttyclock); - free(ttyclock->option.format); exit(EXIT_SUCCESS); break; case 's': @@ -488,8 +494,6 @@ main(int argc, char **argv) key_event(); } - free(ttyclock); - free(ttyclock->option.format); endwin(); return 0; From 9cde0203f9164826804d2775f721ef2e8a435b75 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Mon, 15 Aug 2011 22:01:30 -0400 Subject: [PATCH 11/26] * Remove execute permissions from Makefile and README --- Makefile | 0 README | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Makefile mode change 100755 => 100644 README diff --git a/Makefile b/Makefile old mode 100755 new mode 100644 diff --git a/README b/README old mode 100755 new mode 100644 From 31529219f9b8dd13208e3945a5d3571c8bc65588 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Tue, 16 Aug 2011 16:14:28 -0400 Subject: [PATCH 12/26] Update manpage to reflect recent merging and rearrange the order of the commands a little bit. --- tty-clock.1 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tty-clock.1 b/tty-clock.1 index 86acab3..663ade6 100644 --- a/tty-clock.1 +++ b/tty-clock.1 @@ -7,7 +7,7 @@ tty-clock - a terminal digital clock .SH SYNOPSIS .LP -\fBtty\-clock [\-sbctrvih] [\-C [\fP\fI0\-7\fP\fB]] [\-f\fP \fIformat\fP\fB] [\-d \fIdelay\fP\fB]\fP +\fBtty\-clock [\-sSbctrvih] [\-C [\fP\fI0\-7\fP\fB]] [\-f\fP \fIformat\fP\fB] [\-d \fIdelay\fP\fB]\fP .SH DESCRIPTION .LP \fItty-clock\fP displays a simple digital clock on the terminal @@ -20,11 +20,8 @@ K,J,H,L vi-style movement commands to set the position of the displayed clock. These commands have no effect when the \fBcentered\fP option is set. .TP -S -Display seconds. -.TP -T -Switch time output to the 12-hour format. +B +Toggles displaying a box around the clock. options is disabled by default. .TP C Toggle the clock's position to \fBcentered\fP. @@ -33,6 +30,12 @@ When set the movement commands are disabled. R Set the clock to \fBrebound\fP along the edges of the terminal. .TP +S +Display seconds. +.TP +T +Switch time output to the 12-hour format. +.TP Q Quit. .SH OPTIONS @@ -41,6 +44,9 @@ Quit. \fB\-s\fR Show seconds. .TP +\fB-S\fR +Screensaver mode. tty\-clock terminates when any key is pressed. +.TP \fB\-b\fR Show box. .TP From 6607fc1a634769e1aa3e011a232ee39e4be4f0ed Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Tue, 16 Aug 2011 22:03:13 -0400 Subject: [PATCH 13/26] * Add the -T and -n options to facilitate use through inittab(5) * Update and fix the man page. * Adjust default date format which was left over from a previous failed merge. --- tty-clock.1 | 47 +++++++++++++++++++++++++++++++++++------------ ttyclock.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ ttyclock.h | 9 +++++++++ 3 files changed, 91 insertions(+), 18 deletions(-) diff --git a/tty-clock.1 b/tty-clock.1 index 663ade6..f52b778 100644 --- a/tty-clock.1 +++ b/tty-clock.1 @@ -7,28 +7,30 @@ tty-clock - a terminal digital clock .SH SYNOPSIS .LP -\fBtty\-clock [\-sSbctrvih] [\-C [\fP\fI0\-7\fP\fB]] [\-f\fP \fIformat\fP\fB] [\-d \fIdelay\fP\fB]\fP +\fBtty\-clock [\-sSbctrvih] [\-C [\fI0\-7\fB]] [\-f \fIformat\fB] [\-d \fIdelay\fB] \fB[\-T \fItty\fB]\fR .SH DESCRIPTION .LP -\fItty-clock\fP displays a simple digital clock on the terminal +\fItty-clock\fR displays a simple digital clock on the terminal. Invoked without options +it will display the clock on the upper left corner of the screen on the terminal it was +executed from. .SH COMMANDS .LP -\fItty-clock\fP accepts a number of runtime keyboard commands, upper and lower case characters are +\fItty-clock\fR accepts a number of runtime keyboard commands, upper and lower case characters are treated identically. .TP K,J,H,L vi-style movement commands to set the position of the displayed clock. -These commands have no effect when the \fBcentered\fP option is set. +These commands have no effect when the \fBcentered\fR option is set. .TP B -Toggles displaying a box around the clock. options is disabled by default. +Toggles displaying a box around the clock. This option is disabled by default. .TP C -Toggle the clock's position to \fBcentered\fP. +Toggle the clock's position to \fBcentered\fR. When set the movement commands are disabled. .TP R -Set the clock to \fBrebound\fP along the edges of the terminal. +Set the clock to \fBrebound\fR along the edges of the terminal. .TP S Display seconds. @@ -53,17 +55,27 @@ Show box. \fB\-c\fR Set the clock at the center of the terminal .TP -\fB\-C\fR \fI[0\-7]\fP +\fB\-C\fR \fI[0\-7]\fR Set the clock color. .TP \fB\-t\fR Set the hour in 12h format. .TP +\fB\-T\fR \fItty\fR +Display the clock on the given \fItty\fR. \fItty\fR must be +a valid character device to which the user has rw access permissions. +(See \fBEXAMPLES\fR) +.TP \fB\-r\fR Do rebound the clock. .TP -\fB\-f\fR \fIformat\fP -Set the date format as described in \fBstrftime(3)\fP. +\fB\-f\fR \fIformat\fR +Set the date format as described in \fBstrftime(3)\fR. +.TP +\fB\-n\fR +Do not quit the program when the Q key is pressed (or when any +key is pressed while in \fBScreensaver\fR mode). A signal must +be sent to \fItty\-clock\fR in order to terminate its execution. (See \fBEXAMPLES\fR) .TP \fB\-v\fR Show tty\-clock version. @@ -74,9 +86,20 @@ Show some info about tty\-clock. \fB\-h\fR Show usage information. .TP -\fB\-d\fR \fIdelay\fP +\fB\-d\fR \fIdelay\fR Set the delay between two redraws of the clock. -.SH "AUTHOR" +.SH "EXAMPLES" +.LP +The following example displays a fullscreen clock at boot on one of +the Virtual Terminals on a Linux system using an +.B inittab(5) +entry: +.IP +# /etc/inittab: +.br +9:2345:respawn:/usr/bin/tty-clock -c -n -T /dev/tty9 +.LP +.SH "AUTHORS" Written by Martin Duquesnoy . .LP manpage written by Carla Valenti . diff --git a/ttyclock.c b/ttyclock.c index bc7afbb..dcce97c 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -39,7 +39,19 @@ init(void) ttyclock->bg = COLOR_BLACK; /* Init ncurses */ - initscr(); + if (ttyclock->tty) { + FILE *ftty = fopen(ttyclock->tty, "r+"); + if (!ftty) { + fprintf(stderr, "tty-clock: error: '%s' couldn't be opened: %s.\n", + ttyclock->tty, strerror(errno)); + exit(EXIT_FAILURE); + } + ttyclock->ttyscr = newterm(NULL, ftty, ftty); + assert(ttyclock->ttyscr != NULL); + set_term(ttyclock->ttyscr); + } else + initscr(); + cbreak(); noecho(); keypad(stdscr, True); @@ -138,6 +150,11 @@ signal_handler(int signal) void cleanup(void) { + if (ttyclock->ttyscr) + delscreen(ttyclock->ttyscr); + + if (ttyclock && ttyclock->tty) + free(ttyclock->tty); if (ttyclock && ttyclock->option.format) free(ttyclock->option.format); if (ttyclock) @@ -366,7 +383,7 @@ key_event(void) if (ttyclock->option.screensaver) { c = wgetch(stdscr); - if(c != ERR) + if(c != ERR && ttyclock->option.noquit == False) { ttyclock->running = False; } @@ -421,7 +438,8 @@ key_event(void) case 'q': case 'Q': - ttyclock->running = False; + if (ttyclock->option.noquit == False) + ttyclock->running = False; break; case 's': @@ -476,11 +494,13 @@ main(int argc, char **argv) /* Alloc ttyclock */ ttyclock = malloc(sizeof(ttyclock_t)); + assert(ttyclock != NULL); + memset(ttyclock, 0, sizeof(ttyclock_t)); /* Date format */ ttyclock->option.format = malloc(sizeof(char) * 100); /* Default date format */ - strncpy(ttyclock->option.format, "%d/%m/%Y", 100); + strncpy(ttyclock->option.format, "%F", 100); /* Default color */ ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */ /* Default delay */ @@ -488,21 +508,23 @@ main(int argc, char **argv) atexit(cleanup); - while ((c = getopt(argc, argv, "tvsSrcihbf:d:C:")) != -1) + while ((c = getopt(argc, argv, "tT:nvsSrcihbf:d:C:")) != -1) { switch(c) { case 'h': default: - printf("usage : tty-clock [-sSbctrvih] [-C [0-7]] [-f format] [-d delay] \n" + printf("usage : tty-clock [-sSbctrnvih] [-C [0-7]] [-f format] [-d delay] [-T tty] \n" " -s Show seconds \n" " -S Screensaver mode \n" " -b Show box \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" + " -T tty Display the clock on the specified terminal \n" " -r Do rebound the clock \n" " -f format Set the date format \n" + " -n Don't quit on keypress \n" " -v Show tty-clock version \n" " -i Show some info about tty-clock \n" " -h Show this page \n" @@ -546,6 +568,25 @@ main(int argc, char **argv) case 'b': ttyclock->option.box = True; break; + case 'T': { + struct stat sbuf; + if (stat(optarg, &sbuf) == -1) { + fprintf(stderr, "tty-clock: error: couldn't stat '%s': %s.\n", + optarg, strerror(errno)); + exit(EXIT_FAILURE); + } else if (!S_ISCHR(sbuf.st_mode)) { + fprintf(stderr, "tty-clock: error: '%s' doesn't appear to be a character device.\n", + optarg); + exit(EXIT_FAILURE); + } else { + if (ttyclock->tty) + free(ttyclock->tty); + ttyclock->tty = strdup(optarg); + }} + break; + case 'n': + ttyclock->option.noquit = True; + break; } } diff --git a/ttyclock.h b/ttyclock.h index dd1462e..da14d4b 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -33,8 +33,12 @@ #ifndef TTYCLOCK_H_INCLUDED #define TTYCLOCK_H_INCLUDED +#include +#include +#include #include #include +#include #include #include #include @@ -55,6 +59,10 @@ typedef struct { /* while() boolean */ Bool running; + + /* terminal variables */ + SCREEN *ttyscr; + char *tty; int bg; /* Running option */ @@ -66,6 +74,7 @@ typedef struct Bool center; Bool rebound; Bool box; + Bool noquit; char *format; int color; long delay; From d45b3cf68b632d75a91b311e69214fb62fca8979 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Tue, 16 Aug 2011 22:17:51 -0400 Subject: [PATCH 14/26] * Update README * Document the [0-7] keyboard commands --- README | 2 ++ tty-clock.1 | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README b/README index 0d69cfc..6ce0418 100644 --- a/README +++ b/README @@ -6,7 +6,9 @@ usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format] -C [0-7] Set the clock color -t Set the hour in 12h format -r Do rebound the clock + -T tty Display the clock on the specified terminal -f format Set the date format + -n Don't quit on keypress -v Show tty-clock version -i Show some info about tty-clock -h Show this page diff --git a/tty-clock.1 b/tty-clock.1 index f52b778..ebd72d5 100644 --- a/tty-clock.1 +++ b/tty-clock.1 @@ -22,6 +22,9 @@ K,J,H,L vi-style movement commands to set the position of the displayed clock. These commands have no effect when the \fBcentered\fR option is set. .TP +[0-7] +Select a different color for displaying the clock. +.TP B Toggles displaying a box around the clock. This option is disabled by default. .TP From 1c3e60e0cf1ca6d1185775fcaef9208a195a5dd1 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Tue, 16 Aug 2011 22:21:46 -0400 Subject: [PATCH 15/26] * Update README (2) --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 6ce0418..79150dc 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -usage : tty-clock [-sSctrvih] [-C [0-7]] [-f format] +usage : tty-clock [-sSbctrnvih] [-C [0-7]] [-f format] [-T tty] -s Show seconds -b Show box -S Screensaver mode From c21d6e7316dd36ebd0722be21b851a355eec3820 Mon Sep 17 00:00:00 2001 From: Carla Valenti Date: Tue, 16 Aug 2011 22:54:55 -0400 Subject: [PATCH 16/26] README: * Clarify the -d option * Updates EXAMPLES Section --- tty-clock.1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tty-clock.1 b/tty-clock.1 index ebd72d5..9db5067 100644 --- a/tty-clock.1 +++ b/tty-clock.1 @@ -90,11 +90,19 @@ Show some info about tty\-clock. Show usage information. .TP \fB\-d\fR \fIdelay\fR -Set the delay between two redraws of the clock. +Set the delay (in nanoseconds) between two redraws of the clock. .SH "EXAMPLES" .LP -The following example displays a fullscreen clock at boot on one of -the Virtual Terminals on a Linux system using an +To invoke +.I tty\-clock +in screensaver mode with the clock display set to rebound and the update +delay set to 1/10th of a second (10 FPS): +.IP +$ tty\-clock -Srd 100000000 +.LP +The following example arranges for \fItty-clock\fR to be displayed +indefinitely on one of the Virtual Terminals on a Linux system +at boot time using an .B inittab(5) entry: .IP From bc7ac26be58fec8b4d71dd193a0643d214cef27a Mon Sep 17 00:00:00 2001 From: carla-v Date: Thu, 20 Dec 2012 11:59:24 -0500 Subject: [PATCH 17/26] Makefile: Fix compiler flags * Reorder LDFLAGS to be passed after -o * Get compiler/linker options from the system with ncurses5-config --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0eac46d..6587ec5 100644 --- a/Makefile +++ b/Makefile @@ -8,15 +8,15 @@ BIN = tty-clock PREFIX ?= /usr/local INSTALLPATH = ${DESTDIR}${PREFIX}/bin MANPATH = ${DESTDIR}${PREFIX}/share/man/man1 -CFLAGS = -Wall -g -LDFLAGS = -lncurses +CFLAGS = -Wall -g -I $$(ncurses5-config --includedir) +LDFLAGS = -L $$(ncurses5-config --libdir) $$(ncurses5-config --libs) tty-clock : ${SRC} @echo "build ${SRC}" @echo "CC ${CFLAGS} ${LDFLAGS} ${SRC}" - @${CC} ${CFLAGS} ${LDFLAGS} ${SRC} -o ${BIN} + @${CC} ${CFLAGS} ${SRC} -o ${BIN} ${LDFLAGS} install : ${BIN} From 8eb31f58e5418052cf390097fa8451583ec48492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Wed, 6 Mar 2013 15:37:13 +0100 Subject: [PATCH 18/26] added bold colors and removed the frame --- ttyclock.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/ttyclock.c b/ttyclock.c index bd0c478..49852c4 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -55,6 +55,9 @@ init(void) init_pair(0, ttyclock->bg, ttyclock->bg); init_pair(1, ttyclock->bg, ttyclock->option.color); init_pair(2, ttyclock->option.color, ttyclock->bg); +// init_pair(0, ttyclock->bg, ttyclock->bg); +// init_pair(1, ttyclock->bg, ttyclock->option.color); +// init_pair(2, ttyclock->option.color, ttyclock->bg); refresh(); /* Init signal handler */ @@ -86,7 +89,13 @@ init(void) ttyclock->geo.w, ttyclock->geo.x, ttyclock->geo.y); - box(ttyclock->framewin, 0, 0); + //box(ttyclock->framewin, 0, 0); + wborder(ttyclock->framewin,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + + if (ttyclock->option.bold) + { + wattron(ttyclock->framewin, A_BLINK); + } /* Create the date win */ if (ttyclock->option.date) @@ -95,7 +104,8 @@ init(void) ttyclock->geo.x + ttyclock->geo.h - 1, ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1); - box(ttyclock->datewin, 0, 0); + //box(ttyclock->datewin, 0, 0); + wborder(ttyclock->datewin,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); clearok(ttyclock->datewin, True); } @@ -192,6 +202,12 @@ draw_number(int n, int x, int y) sy = y; ++x; } + + if (ttyclock->option.bold) + wattron(ttyclock->framewin, A_BLINK); + else + wattroff(ttyclock->framewin, A_BLINK); + wbkgdset(ttyclock->framewin, COLOR_PAIR(number[n][i/2])); mvwaddch(ttyclock->framewin, x, sy, ' '); } @@ -217,6 +233,11 @@ draw_clock(void) draw_number(ttyclock->date.minute[1], 1, 27); /* Draw the date */ + if (ttyclock->option.bold) + wattron(ttyclock->datewin, A_BOLD); + else + wattroff(ttyclock->datewin, A_BOLD); + if (ttyclock->option.date) { wbkgdset(ttyclock->datewin, (COLOR_PAIR(2))); @@ -269,11 +290,13 @@ clock_move(int x, int y, int w, int h) ttyclock->geo.x + ttyclock->geo.h - 1, ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1); wresize(ttyclock->datewin, DATEWINH, strlen(ttyclock->date.datestr) + 2); - box(ttyclock->datewin, 0, 0); + //box(ttyclock->datewin, 0, 0); + wborder(ttyclock->datewin,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wrefresh(ttyclock->datewin); } - box(ttyclock->framewin, 0, 0); + //box(ttyclock->framewin, 0, 0); + wborder(ttyclock->framewin,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wrefresh(ttyclock->framewin); return; @@ -398,6 +421,11 @@ key_event(void) set_center(!ttyclock->option.center); break; + case 'b': + case 'B': + ttyclock->option.bold = !ttyclock->option.bold; + break; + case 'r': case 'R': ttyclock->option.rebound = !ttyclock->option.rebound; @@ -438,7 +466,7 @@ main(int argc, char **argv) /* Default delay */ ttyclock->option.delay = 40000000; /* 25FPS */ - while ((c = getopt(argc, argv, "tvsrcihfDd:C:")) != -1) + while ((c = getopt(argc, argv, "btvsrcihfDd:C:")) != -1) { switch(c) { @@ -448,6 +476,7 @@ main(int argc, char **argv) " -s Show seconds \n" " -c Set the clock at the center of the terminal \n" " -C [0-7] Set the clock color \n" + " -b Use bold colors \n" " -t Set the hour in 12h format \n" " -r Do rebound the clock \n" " -f format Set the date format \n" @@ -477,6 +506,9 @@ main(int argc, char **argv) case 'c': ttyclock->option.center = True; break; + case 'b': + ttyclock->option.bold = True; + break; case 'C': if(atoi(optarg) >= 0 && atoi(optarg) < 8) ttyclock->option.color = atoi(optarg); @@ -501,7 +533,7 @@ main(int argc, char **argv) } init(); - + attron(A_BLINK); while(ttyclock->running) { clock_rebound(); From 0b1609f421e97ef00d93e49f5d61e02dc397a1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Wed, 6 Mar 2013 15:43:48 +0100 Subject: [PATCH 19/26] added bold-color option and updated the README --- README | 23 +++++++++++++---------- ttyclock.h | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README b/README index e18294d..397e24f 100755 --- a/README +++ b/README @@ -1,10 +1,13 @@ -usage : tty-clock [-sctrvih] [-C [0-7]] [-f format] - -s Show seconds - -c Set the clock at the center of the terminal - -C [0-7] Set the clock color - -t Set the hour in 12h format - -r Do rebound the clock - -f format Set the date format - -v Show tty-clock version - -i Show some info about tty-clock - -h Show this page +usage : tty-clock [-sctrvihD] [-C [0-7]] [-f format] + -s Show seconds + -c Set the clock at the center of the terminal + -C [0-7] Set the clock color + -b Use bold colors + -t Set the hour in 12h format + -r Do rebound the clock + -f format Set the date format + -v Show tty-clock version + -i Show some info about tty-clock + -h Show this page + -d delay Set the delay between two redraws of the clock + -D Hide date diff --git a/ttyclock.h b/ttyclock.h index d6048f3..ede96b7 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -67,6 +67,7 @@ typedef struct Bool date; char *format; int color; + Bool bold; long delay; } option; From 6e9d5ba2735247be4eb56dd707454a697bf7e8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Wed, 6 Mar 2013 15:45:36 +0100 Subject: [PATCH 20/26] fixed a typo --- ttyclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 49852c4..bc07d49 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -472,7 +472,7 @@ main(int argc, char **argv) { case 'h': default: - printf("usage : tty-clock [-sctrvihD] [-C [0-7]] [-f format] \n" + printf("usage : tty-clock [-scbtrvihD] [-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" From 7cbfead66d613b9c7e50f813ab32d316579be6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Wed, 6 Mar 2013 15:46:43 +0100 Subject: [PATCH 21/26] updated README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 397e24f..4fdeab1 100755 --- a/README +++ b/README @@ -1,4 +1,4 @@ -usage : tty-clock [-sctrvihD] [-C [0-7]] [-f format] +usage : tty-clock [-scbtrvihD] [-C [0-7]] [-f format] -s Show seconds -c Set the clock at the center of the terminal -C [0-7] Set the clock color From 35eab7950dc7fb3836bab6fc28ff8147791a5631 Mon Sep 17 00:00:00 2001 From: Grey Date: Thu, 3 Oct 2013 20:53:46 +0100 Subject: [PATCH 22/26] Implemented delay in seconds for lower CPU usage --- tty-clock.1 | 9 +++++++-- ttyclock.c | 20 +++++++++++++------- ttyclock.h | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tty-clock.1 b/tty-clock.1 index 9db5067..10498e4 100644 --- a/tty-clock.1 +++ b/tty-clock.1 @@ -90,7 +90,10 @@ Show some info about tty\-clock. Show usage information. .TP \fB\-d\fR \fIdelay\fR -Set the delay (in nanoseconds) between two redraws of the clock. +Set the delay (in seconds) between two redraws of the clock. Default 1s. +.TP +\fB\-D\fR \fInsdelay\fR +Additional delay (in nanoseconds) between two redraws of the clock. Default 0ns. .SH "EXAMPLES" .LP To invoke @@ -98,7 +101,7 @@ To invoke in screensaver mode with the clock display set to rebound and the update delay set to 1/10th of a second (10 FPS): .IP -$ tty\-clock -Srd 100000000 +$ tty\-clock -SrD 100000000 -d 0 .LP The following example arranges for \fItty-clock\fR to be displayed indefinitely on one of the Virtual Terminals on a Linux system @@ -115,6 +118,8 @@ Written by Martin Duquesnoy . .LP manpage written by Carla Valenti . .LP +Modified for lower CPU usage by Grey . +.LP Please report .I tty-clock bugs to diff --git a/ttyclock.c b/ttyclock.c index dcce97c..e2c38d3 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -378,7 +378,7 @@ key_event(void) { int i, c; - struct timespec length = { 0, ttyclock->option.delay }; + struct timespec length = { ttyclock->option.delay, ttyclock->option.nsdelay }; if (ttyclock->option.screensaver) { @@ -504,17 +504,18 @@ main(int argc, char **argv) /* Default color */ ttyclock->option.color = COLOR_GREEN; /* COLOR_GREEN = 2 */ /* Default delay */ - ttyclock->option.delay = 40000000; /* 25FPS */ + ttyclock->option.delay = 1; /* 1FPS */ + ttyclock->option.nsdelay = 0; /* -0FPS */ atexit(cleanup); - while ((c = getopt(argc, argv, "tT:nvsSrcihbf:d:C:")) != -1) + while ((c = getopt(argc, argv, "tT:nvsSrcihbf:d:D:C:")) != -1) { switch(c) { case 'h': default: - printf("usage : tty-clock [-sSbctrnvih] [-C [0-7]] [-f format] [-d delay] [-T tty] \n" + printf("usage : tty-clock [-sSbctrnvih] [-C [0-7]] [-f format] [-d delay] [-D nsdelay] [-T tty] \n" " -s Show seconds \n" " -S Screensaver mode \n" " -b Show box \n" @@ -528,11 +529,12 @@ main(int argc, char **argv) " -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"); + " -d delay Set the delay between two redraws of the clock. Default 1s. \n" + " -D nsdelay Additional delay between two redraws in nanoseconds. Default 0ns.\n"); exit(EXIT_SUCCESS); break; case 'i': - puts("TTY-Clock 2 © by Martin Duquesnoy (xorg62@gmail.com)"); + puts("TTY-Clock 2 © by Martin Duquesnoy (xorg62@gmail.com), Grey (grey@greytheory.net)"); exit(EXIT_SUCCESS); break; case 'v': @@ -562,9 +564,13 @@ main(int argc, char **argv) strncpy(ttyclock->option.format, optarg, 100); break; case 'd': - if(atol(optarg) >= 0 && atol(optarg) < 1000000000) + if(atol(optarg) >= 0 && atol(optarg) < 100) ttyclock->option.delay = atol(optarg); break; + case 'D': + if(atol(optarg) >= 0 && atol(optarg) < 1000000000) + ttyclock->option.nsdelay = atol(optarg); + break; case 'b': ttyclock->option.box = True; break; diff --git a/ttyclock.h b/ttyclock.h index da14d4b..5e066a3 100644 --- a/ttyclock.h +++ b/ttyclock.h @@ -78,6 +78,7 @@ typedef struct char *format; int color; long delay; + long nsdelay; } option; /* Clock geometry */ From 4a34f356c6641defc916d884e73ab6756abfa509 Mon Sep 17 00:00:00 2001 From: Grey Date: Thu, 3 Oct 2013 20:59:45 +0100 Subject: [PATCH 23/26] Updated README to reflect delay changes --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 79150dc..5463ed8 100644 --- a/README +++ b/README @@ -12,5 +12,5 @@ usage : tty-clock [-sSbctrnvih] [-C [0-7]] [-f format] [-T tty] -v Show tty-clock version -i Show some info about tty-clock -h Show this page - -d delay Set the delay between two redraws of the clock - + -d delay Set the delay between two redraws of the clock. Default 1s. + -D nsdelay Additional delay between two redraws of the clock in nanoseconds. Default 0ns. From fbb26382afe57d59bb401c6e775d1e9ddf89920f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Mon, 28 Oct 2013 14:00:01 +0100 Subject: [PATCH 24/26] fixed Makefile to work with ncurses and ncursesw --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bccb1c5..a687926 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,16 @@ BIN = tty-clock PREFIX ?= /usr/local INSTALLPATH = ${DESTDIR}${PREFIX}/bin MANPATH = ${DESTDIR}${PREFIX}/share/man/man1 -CFLAGS = -Wall -g -I $$(ncursesw5-config --includedir) -LDFLAGS = -L $$(ncursesw5-config --libdir) $$(ncursesw5-config --libs) + +ifeq ($(shell sh -c 'which ncurses5-config>/dev/null 2>/dev/null && echo y'), y) + CFLAGS = -Wall -g -I $$(ncurses5-config --includedir) + LDFLAGS = -L $$(ncurses5-config --libdir) $$(ncursesw5-config --libs) +else ifeq ($(shell sh -c 'which ncursesw5-config>/dev/null 2>/dev/null && echo y'), y) + CFLAGS = -Wall -g -I $$(ncursesw5-config --includedir) + LDFLAGS = -L $$(ncursesw5-config --libdir) $$(ncursesw5-config --libs) +endif + + tty-clock : ${SRC} From 6fc660a23e09c155783899836d2cebfb09f26265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Mon, 28 Oct 2013 14:15:15 +0100 Subject: [PATCH 25/26] removed a duplicate line in the usage text --- ttyclock.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ttyclock.c b/ttyclock.c index 50c0565..ba6f61a 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -600,7 +600,6 @@ main(int argc, char **argv) " -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" " -D Hide date \n" " -B Enable blinking colon \n" " -d delay Set the delay between two redraws of the clock. Default 1s. \n" From c5a4dc0bce932c467f6cdea6111a4529759a0197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gie=C3=9Fen?= Date: Mon, 28 Oct 2013 14:22:33 +0100 Subject: [PATCH 26/26] fixed README --- README | 1 - 1 file changed, 1 deletion(-) diff --git a/README b/README index d5adac4..66739c6 100644 --- a/README +++ b/README @@ -14,7 +14,6 @@ usage : tty-clock [-iuvsScbtrahDBxn] [-C [0-7]] [-f format] [-d delay] [-a nsdel -v Show tty-clock version -i Show some info about tty-clock -h Show this page - -d delay Set the delay between two redraws of the clock -D Hide date -B Enable blinking colon -d delay Set the delay between two redraws of the clock. Default 1s.