Birthday Reminder Application in Python

In this section we will see how to create a birthday reminder application using Python.

Problem Statement

Create an application using Python, which can check whether there is any birthday on the current day or not. If it is the birthday of some listed person, send a notification to the System with the name of that person.

We need a file, where we can store the date and month and the name of the person as a lookup file for this application. The file will look like this −

Problem Statement

Here we will convert this application to a start-up application to start when the system starts.

Steps to create Birthday Reminder Application

  • Take the lookup file and read from it.
  • Whether the date and month is matched with the current date and month
    • Send notification to the system with all of the names whose birthday is today.
  • Stop

Example Code

importos, time
#Take the birthday lookup file from home directory
file_path = os.getenv('HOME') + '/birth_day_lookup.txt'
   lookup_file = open(file_path, 'r') #open the lookup file as read mode
   today = time.strftime('%d-%B') #get the todays date as dd-Month format
   bday_flag = 0
   #loop through each entry in the birthday file, and check whether the day is present or not
   for entry inlookup_file:
      if today in entry:
         line = entry.split(' ') #cut the line on spaces to get name and surname
         bday_flag = 1
         os.system('notify-send "Today is '+line[1]+' '+line[2]+''s Birthday"')
   ifbday_flag == 0:
      os.system('notify-send "No birthday for today is listed"')



Steps to setup the birthday reminder as the startup application

Step 1 − Convert the script file as executable file by using the chmod command

sudochmod +x

Step 2 − Move the script file to /usr/bin directory.

sudocp /usr/bin

Step 3 − Now search for the Startup Applications, and start it.

Startup Application

After opening the application go to add, and give desired name, then the program name in the command field. And add as startup application.

Command Field
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know