Tuesday, 4 August 2009

Using Conky to display Muslim Prayer Times on Linux

IslamicFinder's Athan is a favourite amongst MS Windows users to display the Muslim prayer times. Some Linux users might wonder whether there are alternatives to Athan for Linux.

There are actually a couple of applications and they all seem to come from Arabeyes.org, which according to the website, is a Meta project aimed at developing a full Arabic UNIX/Linux environment. They've made a Gnome GUI tool called Minbar which has similar functionality (including the sound for the Adhaan). Another Linux application to display prayer times for KDE users is the KPrayertime, again from Arabeyes.org.

I haven't used any of the above programs myself but the installation instructions look pretty straightforward. In this post I'd like to explain how to use another application from Arabeyes called ipraytime together with Conky, a highly extensible desktop monitor for Linux, which will display the prayer times on your desktop. I prefer this method over the former two because Conky is not only able to display useful system stats such as network speed, processor and memory usage but it can also check my Gmail account and Google Calendar appointments. Having the prayer times displayed on my desktop would thus be putting the cherry on the cake. The end result is an elegant, minimalist desktop.

First to start off you need to download and install Conky. A detailed description of the installation and customisation of Conky for Ubuntu can be found here. (even though the instructions are for Ubuntu you can still follow the same instructions for other distributions, for example, I'm using openSUSE).

Once you've installed Conky and become familiar with the configuration file ~/.conkyrc then you need to download the applications that will find the prayer times and display them on the monitor. These applications are part of the Islamic Tools and Libraries (ITL) from Arabeyes.org. You need to download the latest versions of the library (libitl) and itools from here. After which you need to untar the files and go to the directory and install the applications from source. This website gives a method of installing software from source on Linux. This installs the prayer calculator called iprayertime. I prefer to define my configuration in iprayertime's configuration file ~/.iprayrc (please refer to the man pages of iprayertime for more details on configuring the correct latitude, longitude etc.).

Now to pass this information from iprayercalculator to Conky you need to write the following bash script, which is essentially parsing out the information from ipraytime using awk.

#!/bin/bash
ipraytime | awk 'NR==12 {print "Fajr\t\t "$2"\nShurooq\t"$3"\n" "Zuhur\t\t "$4"\nAsr\t\t "$5"\nMaghrib\t "$6"\nIsha\t\t "$7}'


Save this script as, say, prayer.sh (remember to make it executable for the user using chmod u+x prayer.sh) in your scripts directory. You can create a scripts directory if you don't already have one, for example mine is at /home/user/scripts (replace user with your own username).

Then in your ~/.conkyrc you need to add the following line, which is basically calling the script you created in the previous step (remember to specify the correct directory path where your script is located).

{color1}${font}${execi 40000 /home/user/scripts/prayer.sh}

That's all there is to it! Here's a screen shot of what my desktop looks now. As you can see I've used Conky to display a variety of useful information. Hope this was useful for those Linux users looking for an application to display prayer times on their desktop.