Show date and time in Xubuntu (as well as other Linux distros)

Microsoft Windows 8.1 has a very neat little feature I use a lot: you can hit “win+c” to bring up the “charm” which shows the clock along with a few other things. For me that ability to see the current date and time makes this “charm” useful. On a side note, I really do not know what that word “charm” means in the Microsoft world but let’s not digress

The fact is that I use my Xubuntu machines more often than my Windows machine. So, I wanted that “show the clock” ability on my Xubuntu 13.10. I basically wanted to hit “win+c”, like in Windows 8.1, and have the current date and time shown in a pop-up-window on my desktop.

I figured I could easily do this with a shell script. Ages ago, I had very briefly played with a command called Zenity. Zenity is a command line program from the GNOME world that lets you show various graphical dialogs. Basically, Zenity lets you add GUI to your shell script.

Knowing all that, I fired up a terminal and read through the man page for Zenity. After a few minutes of playing around with Zenity, I managed to put together a simple script that does what I want: to show the current date and time in a pop-up window on my desktop.

The second part was to associate this script with “win+c” keyboard shortcut. But, before setting up the keyboard shortcut, I put the script into /usr/local/bin on my system and made the script executable. Then, using the “application shortcuts” tab in “keyboard” settings of the Xubuntu “settings manager” I created the “win+c” keyboard shortcut to launch the script.

The end result of all that activity is that now when i hit “windows+c” i get a quick, big date and time window on my desktop. As currently implemented this date and time window disappears after 10 seconds, but, you could hit escape anytime before that to close the window.

NOTE: This is the output from version 1 of the script. Check the update below for newer version.

This is how my script pops up a window showing current date and time

My (first version) script pops up a window showing current date and time

UPDATE Feb 14, 2014: I updated the script to improve the pop-up window display. Specifically, I changed from Zenity’s “info” to “progress bar” dialog option. I changed a few colors and added text that indicates the window can be closed by hitting Escape key. Here is how the new pop-up window looks:

This is how my script pops up a window showing current date and time

My (second version) script pops up a window showing current date and time along with helpful text hinting how to close the window and a progress bar at the bottom indicating when the window will close by itself.

This script is especially useful to me because:

  • I hate multiple panels on my desktop
  • I “auto-hide” the top panel on my Xubuntu desktop
  • I love keyboard shortcuts!

Even if you do show the top panel on your desktop, this script may be useful because of its big date and time display. Try it to see if it is useful to you. And if you find it useful please leave a good/encouraging comment below … as that would be much appreciated. Please note that all comments are moderated, so some comments may not appear on this blog.

You can download the script from my GitHub Gists. The script carries a GPL license.

Note that the script uses Zenity supported Pango Markup to get the display to look “beautiful” with colors and bold formatting … although, as some Chinese or Western philosopher had said “beauty lies in the eyes of the beholder,” so you may want to change the formatting to suit your needs.

References:

Advertisements