File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Author: OMKAR PATHAK
4+
5+ # This application was developed as I cannot remember for birthdays efficiently.
6+ # This app helps me remine birthdays and notifies me on their birthdays.
7+
8+ # To store birthdays ceate a file 'reminder.data' and store birthdays in this format:
9+ # MonthDay Name Surname
10+
11+ # Copy the python file to /bin:
12+ # sudo cp -i /path/to/your_script.py /bin
13+ # (your_script.py should be executable)
14+ # Add A New Cron Job:
15+ # sudo crontab -e
16+ # Scroll to the bottom and add the following line (after all the #'s):
17+ # @reboot python /bin/your_script.py &
18+ # And Reboot to check if the script is working
19+
20+ # Or simply search for 'Startup applications' and add you script there
21+
22+ import time
23+ import os
24+
25+ birthdayFile = '/home/omkarpathak/Documents/GITs/Python-Programs/Programs/reminder.data'
26+ myFilePath = 'python /home/omkarpathak/Documents/GITs/Python-Programs/Programs/P63_ReminderApplication.py'
27+
28+ def checkStartupScript ():
29+ ''' This function ensures that our application executes on every startup '''
30+ flag = 0
31+ fileName = open ('/etc/rc.local' , 'r' )
32+ for line in fileName :
33+ if myFilePath in line :
34+ flag = 1
35+ if flag == 0 :
36+ addToStartup ()
37+ fileName .close ()
38+
39+ def addToStartup ():
40+ fileName = open ('/etc/rc.local' , 'a' )
41+ fileName .write (myFilePath + '\n ' )
42+ fileName .close ()
43+
44+ def checkTodaysBirthdays ():
45+ fileName = open (birthdayFile , 'r' )
46+ today = time .strftime ('%m%d' )
47+ flag = 0
48+ for line in fileName :
49+ if today in line :
50+ line = line .split (' ' )
51+ flag = 1
52+ os .system ('notify-send "Birthdays Today: ' + line [1 ] + ' ' + line [2 ] + '"' )
53+ if flag == 0 :
54+ os .system ('notify-send "No Birthdays Today!"' )
55+
56+ if __name__ == '__main__' :
57+ checkStartupScript ()
58+ checkTodaysBirthdays ()
You can’t perform that action at this time.
0 commit comments