Browse files

Merge pull request #19 from cgie/master

Several features
  • Loading branch information...
2 parents d9875dc + c5a4dc0 commit 4e6b4cae8aad23bd52ab17134ea32ef5619fcfb0 @xorg62 committed Oct 28, 2013
Showing with 358 additions and 48 deletions.
  1. +28 −13 Makefile
  2. +9 −3 README
  3. +131 −0 tty-clock.1
  4. +176 −32 ttyclock.c
  5. +14 −0 ttyclock.h
41 Makefile 100755 → 100644
@@ -5,35 +5,50 @@
SRC = ttyclock.c
CC ?= gcc
BIN = tty-clock
-INSTALLPATH = /usr/local/bin/
-CFLAGS ?= -O2 -g
-CFLAGS += -Wall $(shell pkg-config --cflags ncurses 2>/dev/null)
-LIBS = $(shell pkg-config --libs ncurses 2>/dev/null | echo -lncurses)
+PREFIX ?= /usr/local
+MANPATH = ${DESTDIR}${PREFIX}/share/man/man1
+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)
tty-clock : ${SRC}
@echo "build ${SRC}"
+ @echo "CC ${CFLAGS} ${LDFLAGS} ${SRC}"
+ @${CC} ${CFLAGS} ${SRC} -o ${BIN} ${LDFLAGS}
install : ${BIN}
- @echo "creating target folder in ${DESTDIR}${INSTALLPATH}"
- @mkdir -p "${DESTDIR}${INSTALLPATH}"
- @echo "installing binary file to ${DESTDIR}${INSTALLPATH}${BIN}"
- @chmod 755 "${DESTDIR}${INSTALLPATH}${BIN}"
+ @echo "installing binary file to ${INSTALLPATH}/${BIN}"
+ @mkdir -p ${INSTALLPATH}
+ @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 (${DESTDIR}${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"
12 README 100755 → 100644
@@ -1,14 +1,20 @@
-usage : tty-clock [-sctrvihDB] [-C [0-7]] [-f format]
+usage : tty-clock [-iuvsScbtrahDBxn] [-C [0-7]] [-f format] [-d delay] [-a nsdelay] [-T tty]
-s Show seconds
+ -S Screensaver mode
+ -x Show box
-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
- -u Use UTC time
+ -u Use UTC time
+ -T tty Display the clock on the specified terminal
-r Do rebound the clock
-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
- -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.
+ -a nsdelay Additional delay between two redraws in nanoseconds. Default 0ns.
@@ -0,0 +1,131 @@
+.\" This manpage was written by Carla Valenti <>
+.\" and Christian Giessen <> for tty-clock.
+.\" In details the command line options displayed by tty-clock -h as
+.\" well as the keyboard commands.
+.TH "TTY-CLOCK" "1" "October 2013" "" "User Commands"
+tty\-clock \- a terminal digital clock
+\fBtty\-clock [\-iuvsScbtrahDBxn] [\-C [\fI0\-7\fB]] [\-f \fIformat\fB] [\-d \fIdelay\fB] [\-a \fInsdelay\fB] \fB[\-T \fItty\fB]\fR
+\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.
+\fItty\-clock\fR accepts a number of runtime keyboard commands, upper and lower case characters are
+treated identically.
+vi\-style movement commands to set the position of the displayed clock.
+These commands have no effect when the \fBcentered\fR option is set.
+Select a different color for displaying the clock.
+Toggles bewteen bold and normal colors.
+Toggles displaying a box around the clock. This option is disabled by default.
+Toggle the clock's position to \fBcentered\fR.
+When set the movement commands are disabled.
+Set the clock to \fBrebound\fR along the edges of the terminal.
+Display seconds.
+Switch time output to the 12\-hour format.
+Show seconds.
+Screensaver mode. tty\-clock terminates when any key is pressed.
+Show box.
+Set the clock at the center of the terminal.
+\fB\-C\fR \fI[0\-7]\fR
+Set the clock color.
+Use bold colors.
+Set the hour in 12h format.
+Use UTC time.
+\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.
+Do rebound the clock.
+\fB\-f\fR \fIformat\fR
+Set the date format as described in \fBstrftime(3)\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)
+Show tty\-clock version.
+Show some info about tty\-clock.
+Show usage information.
+Hide the date.
+Enable blinking colon.
+\fB\-d\fR \fIdelay\fR
+Set the delay (in seconds) between two redraws of the clock. Default 1s.
+\fB\-a\fR \fInsdelay\fR
+Additional delay (in nanoseconds) between two redraws of the clock. Default 0ns.
+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):
+$ tty\-clock \-Sra 100000000 \-d 0
+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)
+# /etc/inittab:
+9:2345:respawn:/usr/bin/tty\-clock \-c \-n \-T /dev/tty9
Oops, something went wrong.

0 comments on commit 4e6b4ca

Please sign in to comment.