On screen time display

Today I liked to know the time. I don't have a clock and on my computer it's to much work to show the time. I use ion3 and it can show the time in a statusbar, but I don't like that, because it takes too much of my screen real estate.

So I created a little program that shows the time for a few seconds in the right bottom corner of my screen. It's called (how original) osdtime.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include <xosd.h>
#include <time.h>

/* seconds to display time */
int seconds_to_display = 3;

/* display font */
const char* display_font = "-adobe-helvetica-bold-r-normal-*-*-320-*-*-p-*-*";

/* time format string */
const char* time_fmt = "%H:%M:%S";

/* text-colour */
const char* text_colour = "white";

/* outline-colour */
const char* outline_colour = "black";

int main(int argc, char *argv[])
  xosd *osd;
  setlocale(LC_ALL, "");
  osd = xosd_create(2);
  if (osd == NULL) {
    perror("Could not create \"osd\"");
  /* Set the position of the display. */
  xosd_set_pos(osd, XOSD_bottom);
  xosd_set_align(osd, XOSD_right);

  /* Set the font and the colours. */
  xosd_set_font(osd, display_font);
  xosd_set_colour(osd, text_colour);

  xosd_set_outline_offset(osd, 2);
  xosd_set_outline_colour(osd, outline_colour);

  /* Display the time for some seconds. */
  int i;
  for (i = 0; i < seconds_to_display; i++) {
    time_t tm;
    struct tm *localtm;
    localtm = localtime(&tm);

    char buf[9];
    strftime(buf, 9, time_fmt, localtm);

    xosd_display(osd, 0, XOSD_string, buf);


It uses libxosd to show the text. As always, it comes without any warranty. Use at your own risk. It can be compiled with the following command line.

gcc `xosd-config --libs --cflags` osdtime.c -o osdtime

At the beginning of the program it's possible to set the variables to nicer values if you like.

At the ion3 side of this hack I changed the ~/.ion3/cfg_bindings.lua file. The time will be displayed when I press F11. This can be done by putting the following lines in the bindings file after the line that uses F9.

bdoc("Display the time."),
kpress(MOD2.."F11", "ioncore.exec_on(_, 'osdtime')"),


My name is Peter Stuifzand. You're reading my personal website.