Results 1 to 7 of 7
I'm looking to write a shell script that is a count down counter for my brothers birthday, hopfully something that when the big day comes it pops up and says ...
- 02-16-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 5
Countdown Timer
I'm looking to write a shell script that is a count down counter for my brothers birthday, hopfully something that when the big day comes it pops up and says " happy birthday"
something that wont get screwed up if the computer is restarted...
- 02-16-2010 #2
not quite sure what you mean by "a count down counter". basically if you want something to happen on a particular date you can use cron (man crontab to see examples). you could use something like zenity to pop up a "happy birthday!" window, or even mplayer to play an animation and/or music etc.
if you're wanting something to display how many days remain to your brother's birthday, you could look for some kind of panel or desktop widget for this purpose (in xfce the "genmon" or "generic monitor" panel applet is a nice one that will display the output of a script). if you're wanting something to happen whenever you log in ("x days to brother's birthday...") you could just pop it (a zenity script or whatever) into your startup directory (i.e. write a foo.desktop file to launch the script, and put the foo.desktop file in .config/autostart).
your calendar or organiser may have a solution built-in, too: some will launch programs at particular times.
- 02-17-2010 #3Just Joined!
- Join Date
- Jun 2007
- Posts
- 9
Here's something I saw in Perl.
#!/usr/bin/perl
# perl binary
@std_date=(1,1,1800); # cal starts from this year
@date_one=(21,06,2006); # first date
@date_two=(20,06,2007); # second date
@days_of_month=(31,28,31,30,31,30,31,31,30,31,30,3 1);
$count1=no_day(@std_date,@date_one); # date_one - std_date
$count2=no_day(@std_date,@date_two); # date_two - std_date
$count=($count1 > $count2) ? $count1 - $count2 : $count2 - $count1;
# date1 - date2
print "\n\tNo of days : $count\n\n";
sub no_day
{
@std=($_[0],$_[1],$_[2]);
@date=($_[3],$_[4],$_[5]);
$count=0;
#adding the days for year
for($i=$std[2];$i<$date[2];$i++)
{
$count+=365 if(leapyear($i));
$count+=366 if(!(leapyear($i)));
}
#adding the days for month
for($i=@std[1];$i<$date[1];$i++)
{
$count+=$days_of_month[$i-1];
}
#adding the days and return
return($count+=$date[0]);
}
sub leapyear # is it leap year
{
$in=$_[0];
if(!($in%4))
{
if($in%100)
{
return(0); # if leap year
}
else
{
if(!($in%400))
{
return(0);
}
return(1)
}
}
return(1); # if it is not leap year
}
I think this might give you a start.
- 02-17-2010 #4Just Joined!
- Join Date
- Jan 2010
- Posts
- 7
i think you mean after the computer restart, your calender would auto restart.
you can setting in your bashrc. Mine is ubuntu, so my bashrc is in ~/.bashrc.
add this line at the end of .bashrc:
xx&
xx = your shell script
i hope it will help
- 02-17-2010 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
I use korganizer for that sort of stuff. It pops up nicely when the trigger date+time arrive. That's primarily for KDE, but there should be something similar for the Gnome desktop as well, if you don't have the korganizer installed on your system. It shouldn't require KDE to run (not 100% sure of that).
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 02-17-2010 #6Just Joined!
- Join Date
- Jan 2010
- Posts
- 7
- 02-17-2010 #7
yep, and xfce's little calendar app ("orage") can also do this. you could create a recurring (daily) event, and attach an alarm (which can include launching any app or script) to that.


Reply With Quote
