PDA

View Full Version : Using AppleScript to make daily todos?




luigidorf
Jan 7, 2012, 02:33 AM
I've been trying to figure out a way to make todos (reminders) that recur every day (or week). iCal doesn't have this functionality built in, but it seems possible with AppleScript. The problem is, I am clueless when it comes to AppleScript and I can't get anything to work beyond very simple commands.

If someone has done this, I would be delighted to see the code. I do have some programming experience (mostly C++), so I'm sure if I saw it I would understand it right away.

I'll say the task seems very simple if I can figure out how to access the data and actions in iCal. Here's some pseudo code for what I'd do:
if(time = 00:00)
{
for(each reminder that I want to recur)
{
for(each reminder in iCal)
{
if(name of reminder I want to recur = name of reminder in iCal)
break
make the reminder I want to recur
}
}
}

Can anyone help me translate this into AppleScript?

Thanks in advance!



jiminaus
Jan 7, 2012, 04:35 AM
Edit: Sorry, you're talking about reminders, not events.


iCal does have repeating events. At least iCal under Lion does. I can setup an event to repeat every day, every week, every month or every year. Or I can setup a custom repeat and completely control on which days and at what frequency.

Does this not work for you?

luigidorf
Jan 7, 2012, 06:58 PM
Edit: Sorry, you're talking about reminders, not events.


iCal does have repeating events. At least iCal under Lion does. I can setup an event to repeat every day, every week, every month or every year. Or I can setup a custom repeat and completely control on which days and at what frequency.

Does this not work for you?

I realize I could just have a separate calendar for reminders, and use events instead, but it wouldn't be the same. Even if the functionality were almost identical, I'd still like to be able to do this in AppleScript so I'll be able to apply what I've learned to other scripts.

subsonix
Jan 7, 2012, 07:44 PM
Your script will rely on it running constantly in the background, checking if the current time match your events. If your script gets killed you will oversleep so to speak, what if every script that handle timed events would constantly run? It would be a mess. The os provides mechanisms to handle this for you, use them instead. The simplest is to use cron, and create a crontab to launch your script periodically.

luigidorf
Jan 7, 2012, 10:02 PM
Your script will rely on it running constantly in the background, checking if the current time match your events. If your script gets killed you will oversleep so to speak, what if every script that handle timed events would constantly run? It would be a mess. The os provides mechanisms to handle this for you, use them instead. The simplest is to use cron, and create a crontab to launch your script periodically.

I'll look into cron, thanks for that. Still clueless on the AppleScript thing.

sero
Jan 10, 2012, 05:46 PM
are you familiar with remind (http://linux.die.net/man/1/remind)?

iHutch105
Jan 11, 2012, 06:04 AM
Your pseudo-code suggests that this script will only run at precisely midnight, are you sure that's what you want?

Also, wouldn't it run multiple times per minute?

Just a couple of thoughts.