Automatic B Day Remainder Program

6

Click here to load reader

Transcript of Automatic B Day Remainder Program

Page 1: Automatic B Day Remainder Program

Automatic Birthday Remainder Program

Hi , This Program runs works as Birthday Remainder in our local system . Just try this !

H

It will display our friends name and photo in desktop like notifier whenever u switch on ur system on.

o

It will remaind u on,

I

1) Today's B Day2) Tomorrow's B Day

22

Installation :---------------

-

To Notify :

T

$ sudo apt-get install libnotify-bin

To Ruby :

T

$ sudo apt-get install ruby$ sudo apt-get install rubygems$ sudo gem install activesupport

ss

Datebase :----------

-

In this “database" file which having friends name, dob , image_path.

II

You can edit and add new line in order of name , dob , image_path with separated by comma.

Y

database file: Arulalan,01-01,~/birthday_remainder/Arulalan.jpgDhastha,31-12,default

D

Conditions:

C

1) first field must have name2) second filed have dob. It is date and month order only. date ( from 01 to 31 ) & month ( from 01 to 12 ).The date and month are separeted by minus symbol(-).eg: 09-05 ( 9th day , May month )

e

3) third field have the image location path. This image will be displayed on monitor ( notify )

Page 2: Automatic B Day Remainder Program

create ond directory “ birthday_remainder” in ur home folder.

U can set path like this. eg : ~/birthday_remainder/Arulalan.jpg ( If u stored the image in this folder ) or u can set any image path

f

If u dont have image then set the third field as "default" eg: Dhastha,31-12,default

I

This "default" option will invoke inbuild image path. this inbuild image is stored in "birthday_remainder" folder itself. path is : ~/birthday_remainder/cake.jpeg

""

you may add any no of lines in this database file.

yy

bday.rb:

#!/usr/bin/env rubyrequire "rubygems"require "active_support"

r

sleep(10)

s

file=File.open("database","r")file.each do |bday|bday=bday.chomp!

b

bday=bday.split(/,/)name=bday[0].to_sdob=bday[1].to_simage_path=bday[2].to_s

i

if image_path=="default" thenimage_path="~/birthday_remainder/cake.jpeg"end

e

dob=dob.split(/-/)

d

current_time=Time.nowmonth=current_time.month.to_sday=current_time.day.to_s

d

if month.to_i <10 thenmonth="0"+monthend

ee

tomorrow=1.day.from_now.to_stomorrow=tomorrow.split(/ /)p tomorrow

p

Page 3: Automatic B Day Remainder Program

if dob[1]==month thenif dob[0]==day then

system("notify-send 'BirthDay Remainder' 'Today #{name} Birthday' -i #{image_path} -t 3000")

#

sleep(10)system("notify-send 'BirthDay Remainder' 'Did U wished #{name} Birthday ?' -t

0")

0

end

e

if dob[0]==(tomorrow[2]) thensystem("notify-send 'BirthDay Remainder' 'Tomorrow #{name} Birthday' -i

#{image_path} -t 3000")

#

sleep(10)system("notify-send 'BirthDay Remainder' 'Did U Purchased Gift For #{name}

Birthday ?' -t 0")

B

endend

ee

mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]

m

today=Time.now.to_stoday=today.split(/ /)today[1].to_s

t

x=mon.index(today[1]).to_iy=mon.index(tomorrow[1]).to_i

yyy

if (x+1==y or tomorrow[1]=="Jan" ) and dob[0]=="01" thensystem("notify-send 'BirthDay Remainder' 'Tomorrow #{name} Birthday' -i

#{image_path} -t 3000")

#

sleep(10)system("notify-send 'BirthDay Remainder' 'Did U Purchased Gift For #{name}

Birthday ?' -t 0")

B

end

eee

end

Change Permission :-------------------

-

here , you must make "birthday_remainder" folder in ur home folder and paste this bday.rb and database file and corresponding images .

Page 4: Automatic B Day Remainder Program

d

$ sudo chmod -R 777 ~/ birthday_remainder/

ss

Adding into Start Up Application :----------------------------------

-

In ubuntu 9.10 version :

I

1) Go to "System" -> "Preferences" -> "Startup Applications"2) Click "Add" button3) Now click "Browse" button and comes to home folder-> birthday_remainder folder-> bday.rb ( select bday.rb )4) In Name field , type as " Birthday Remainder"5) Then click "Add" button

5

* u can enable (check box )or edit or remove whatever u add in startup application

**

Logout or Restart :-------------------

-

Now u can see the bday remainder in ur desktop.

NN

How to check :--------------

-

If u wanna to check this program , then u change the dob of database file into curent date.

I

this prog will remaind u today's and tomorrow's b day....

t

* It will remaind u in all calender days like 28,29,30,31 & leap year.Have a fun !

Page 5: Automatic B Day Remainder Program

H

Page 6: Automatic B Day Remainder Program

------------------------------------------------------------------------------------------------------------------------

-

Regads ,

Arulalan.T

Enjoy with Ruby !