Wednesday, October 9, 2013

'' A Simple Python Script To Remind You About Events That You Want To Remember | Pranshu

Written by  | Google+ Pranshu Bajpai | LinkedIn

This is a simple Linux utility that I coded long ago for personal use that would remind me about events that I want to remember. It reminds you of a given event on a certain data after you log onto your computer on that date.

This is a basic script in Python. Please feel free to improve it to suit your particular needs.


-Displays a Graphical Notification in Top Right Corner Each Time you Login
-You Manually Enter Events and Corresponding dates

How to Use:

Create a Folder called "python codes" in your root directory and place "" there

(Path is hard coded in the script. This is bad coding, but I was in a hurry. Like I said, feel free to improve the code)

Create a File in this folder called ""

Enter the Dates and Events in this format and Save:

MonthDay Event
Example for 10th of Oct:
1010 EventName

Add to 'Startup'  (Applications -> System Tools -> Preferences -> Startup)

(I have added a module for 'Auto-Add to Startup' but it was giving issues, so I commented it out, feel free to correct that)

Each Time you login now, remindme will check the file and see if there's an Event listed for today. If an event is listed, it will display a notification:

If you're new to Python you might like to read the code:


import time       #for checking current date
import gtk.gdk    
import pynotify   #For Notifications

today = time.strftime("%m%d")
Remind_Me_Path = "python /root/python\ codes/"  #Path to script

#Following Function that checks whether Startup Entry is already made
#Coz We don't want multiple startup entries made, everytime program runs

def check_startup_entry():                   
 flag = 0
 file = open ("/root/.bash_profile", 'r')
        for line in file:
                if Remind_Me_Path in line:
   flag = 1
 if flag == 0:

#Following Function adds the startup entry if it check_startup didn't find one

def add_to_startup():
 file = open ("/root/.bash_profile", 'a+')

#Following Function checks for Events in file

def check_for_event():
 file = open ("/root/python codes/", 'r')
 for line in file:
  if today in line:

#Following Function is called by check_for_event for notification

def notify(arg):
 n = pynotify.Notification("Remind_Me: " + arg)
 n.set_hint('x', gtk.gdk.screen_width()/2.)
 n.set_hint('y', gtk.gdk.screen_height()/2.)