Banner of Tech Meets Spirituality: Quran Verses on Your Conky Desktop

Quranic Wisdom on Your Desktop: Conky Setup Explained

Category: Linux

Date: 44 days ago
Views: 521

Let me take you through the process of creating a unique Conky setup to display Quran verses on your desktop. This involves a set of Python and shell scripts, along with some Conky configuration magic.

1. Reshaping Arabic Text

To begin, I crafted a Python script,, that handles the reshaping of Arabic text. Leveraging the arabic_reshaper and bidi libraries, the script ensures that the Arabic text is correctly displayed and fits neatly within a specified line length.

# Install the arabic_reshaper package if you haven't already
# You can install it using: pip install arabic-reshaper
# install bidi using      : pip install python-bidi

import arabic_reshaper
from bidi.algorithm import get_display
import sys

def reshape_and_wrap_arabic_text(text, line_length):
    reshaped_text = arabic_reshaper.reshape(text)
    bidi_text = get_display(reshaped_text)

    # Split the text into words
    words = bidi_text.split()

    # Initialize variables
    current_line = ""
    wrapped_lines = []

    # Iterate through words and wrap lines
    for word in words:
        if len(current_line) + len(word) + 1 <= line_length:
            current_line += word + " "
            current_line = word + " "

    # Add the last line

    # Reverse the order of lines to read from bottom up
    wrapped_text = "\n".join(reversed(wrapped_lines))

    return wrapped_text

arabic_text =  sys.argv[1]
wrapped_text = reshape_and_wrap_arabic_text(arabic_text, 100)


screenshot of conky quran
Screenshot 2

2. Fortune and Shell Script Magic


arabic_text="$(fortune "$fortune_data_directory" )"
source "${HOME}/bin/venv/bin/activate"

reshaped_arabic_text=$(python "$python_script" "$arabic_text" )
printf '%s' "$reshaped_arabic_text"

The shell script is the orchestrator of the process. It uses the fortune command to randomly select a Quranic verse from a designated directory. After obtaining the verse, it activates a virtual environment and hands the text to the Python script for reshaping.

3. Crafting the Conky Environment

With the reshaped Arabic text in hand, it's time to showcase it on the desktop using Conky. The following Conky configuration script comes into play, defining the fonts, window properties, colors, and other visual elements. This script transforms the desktop into an elegant canvas for displaying Quran verses.

conky.config = {
    use_xft =true,
    font ='Amiri:size=27',
    xftalpha =0.1,
    update_interval =1,
    total_run_times =0,

    own_window =true,
    own_window_type ="conky",
    own_window_type ="override",
    own_window_transparent =true,
    own_window_hints ="undecorated,below,sticky,skip_taskbar,skip_pager",
    own_window_colour ="000000",
    own_window_argb_visual =true,
    own_window_argb_value =255,

    double_buffer =true,
    minimum_width =1265,
    draw_shades =false,
    draw_outline =false,
    border_width = 1,
    draw_borders =false,
    draw_graph_borders =false,
    default_color ="white",
    default_shade_color ="red",
    default_outline_color ="green",
    alignment ="top_middle",
    gap_x =-10,
    gap_y =160,
    no_buffers =true,
    cpu_avg_samples =2,
    net_avg_samples =1,
    override_utf8_locale =true,
    use_spacer ="none",


conky.text = [[
	${execi 20 /home/mosaid/.i3/conky/conky_quran/ }

screenshot of conky quran
Screenshot 2

How to Use

To integrate this setup, ensure that the required Python libraries are installed. The Conky configuration is set up to point to the shell script, creating a seamless pipeline that fetches, reshapes, and displays a random Quran verse on your desktop at regular intervals.

You can get all the files from this github repo : Conky Quran with fortune

In Conclusion

This personalized Conky Quran display is not just a functional addition but also a visually pleasing one. By combining the flexibility of Conky with the scripting capabilities of Python, you can bring a touch of elegance and inspiration to your desktop with ever-changing Quranic verses.


Previous Article Next Article

3 Comments, latest

  • Elmotaki
    40 days ago



  • admin Admin Reply
    40 days ago


    hello there. I hope the article was helpful to you

  • admin Admin Reply
    40 days ago


    please feel free to contact me if you have any questions, the code is available on github