dclock is a heavily modified version of the original dclock by Dan Heller (email@example.com) if anyone remembers that one any more (actually, it is remembered---it and other old Unix utilities are kept nice and tidy in the " sipb locker". Thanks to Sal Valente (sipb maintainer) for pointing this out to me and correcting the original URL pointer to Dan Heller's source. See below). The original dclock program used very simple calculations to make the digital segments; due to a well-known psychological effect, the numbers seem to lean the wrong way (because almost all LED segments are slightly slanted, and these weren't, although I have seen exceptions). So I studied a digital watch (a Casio, if you must know) closely, and wrote routines to more closely approximate real LED segments, while adding a few extra features as well. Because the LED segments are described by a parameterized geometry, a wide variety of LED styles is possible. Slope, thickness, and spacing of the digits are all independent and continuously-variable parameters.
dclock compiles readily under Linux; its status on other systems is untested since the advent of the new version (please let me know if you try).
Source code available here:
New version based on Xft available here:
Sample dclock window.
Antialiasing is not built into X11, so the routine for generating antialiased filled polygons had to be written by hand. If you think that antialiasing isn't worth the trouble, or just want to see what a difference it makes, then click here to compare against the dclock display from my 1993 version, with ``jaggies''. Note that antialiasing is slow by nature, requiring per-pixel fill operations, but it works here because digits are drawn only once, onto pixmaps, and copied to the window as necessary. Due to the saved pixmaps, making dclock fill your background is bound to be a waste of memory.
Joeri Sebrechts (firstname.lastname@example.org) suggests the color scheme background=black, foreground=lavender, led_off=gray22. With a black screen background, he describes the effect as looking like one of ``those neon blue car radio displays molded into my background. Very cool.'' He made a screenshot of the result, posted here with his permission.
Sample dclock window from the new (July 2008) 2.2 version, using Xft fonts.
August 1999: Added smooth fading to replace the stipple patterns; the program will revert to stipples if it cannot allocate all the colors necessary for the color fade. Added antialiasing to the segment lines for the smoothest graphics possible. Now includes the capability to play audio files for the hourly bell and the alarm, with alarm and bell icons to keep track of the enabled features.
November 1999: Repaired the audio play so that (1) playing the audio file does not leave behind a zombie process and (2) the audio executable can be specified as an X resource. Also put back Dan Heller's original dclock man page, modified to include the new features of this version.
January 2000: Major embarassment! Dclock is not Y2K compliant! Egads! Those who bother displaying the year in 4-digit format (I never do; I know what year it is) will discover that we have reverted to 1900. The Y2K-compliant version was posted January 3. Note that the Y2K-compliant version has taken the very sensible approach suggested by "mho" (email@example.com) of using system function strftime() as the basis of its date-to-string conversion. Thus the format of the format (the meta-format?) has changed.
June 2000: Changed the timeout function from a fixed 1000 msec delay to a delay based on the number of microseconds to the next second boundary, as returned by gettimeofday(). Also added a time check during number fades so that the seconds won't stop counting during that period. Also make seconds digits draw before the minutes digits, so there is no extra delay between 59 and 00 seconds.
December 2000: Added patch by Matt Magri (firstname.lastname@example.org) which added the "-dateup" option to print the date up at the top (out of the way of obscuring windows) and which can be toggled in real-time using the "u" key. Also, he added the "-nomiltime" option which is mentioned in the man page but was heretofore unimplemented.
February 2002: Added window manager hints so that dclock requests input focus from the window manager for mouse clicks and keys. Otherwise, some window managers refuse to give input focus to the dclock window.
April 2002: Added patch by Andy Peterson (email@example.com) which adds the "-utc" option to print the date in universal coordinated time (substitutes gmtime() for localtime()).
January 2005: Altered the timer routine (see June 2000) to aim for about 5ms later than the second boundary. This became a problem with Fedora Core. Due to some change in the scheduling algorithm, it is possible to trigger the timeout a few milliseconds too early, resulting in apparently "skipped" seconds on the clock.
June 2008: Corrected a long-time annoyance, which is the handling of the first "1" digit, such that its background consists only of the two segments used. The original behavior left no segment background when the "1" was not being displayed, and displayed the unused horizontal segments' background (running off the left edge of the window) when it was. Also changed the flashing ":" background to the segment background color, instead of the window background color. Also, added some changes from the Debian branch version, in the hopes that the next Debian version will incorporate the changes I've made in the last few revisions.
June 2008: Corrected a long-time error in the antialiasing routine, which turned out to be due to round-off error producing a small negative number for a (squared) distance metric, then passed to a sqrt() function and resulting in "NaN". The result was occasional pixels being drawn bright foreground color when they should have been close to the background color. Also found another roundoff error in the "insideness" routine (determines if a point is inside a polygon using the winding number), and corrected it. At the same time, I implemented antialiased circles for the colon between hours and minutes.
July 2008: Introduced a new version with date text based on Xft (the anti-aliased font rendering server). The freefont font can be specified on the command line with "-fontName
". These fonts are resized proportionally to the window. I have not (yet) attempted to add support for different font sizes (relative to the window; it is now fixed at 1/6 the window height), or other font properties such as style or weight. I will eventually get around to adding the "AM/PM" string in an Xft font, as well as perhaps playing around with scalable font glyphs for the bell and alarm symbols.
Also: Corrected behavior with respect to resizing in a window manager implementing "opaque resize". Dclock punts on the resize and redraw until all resize events have been processed. There is a slight delay between resizing and redisplay, but this prevents dclock from queueing up many (computationally expensive) resize events. Note: The original dclock is still around, though I have not found it in a packaged form. Try the following link to the "sipb locker" at MIT: Dan Heller's dclock (screenshot).
Back to my home page. . .
---As always, Caveat end-user.
Last updated: July 19, 2012 at 11:57am