Archive for the ‘Apple’ Category

So, Google announced recently that it would support CalDAV syncing with iCal, which means if you update an entry in iCal (or Google Calendar), they’ll be in sync within a few minutes. Awesome.

Unfortunately, it meant that my previous script iteration would now continually add alarms, leading to each entry having 3 or 4 alarms. Turns out that updating a local iCal calendar and adding an alarm actually updates that same info at GCal. Which is awesome (but was unexpected).

So, I made a small tweak to the script, which makes it run a bit faster and makes sure that you only get one alarm on an entry:

Try this instead:

tell application "iCal"
  set theCalendars to {"Cal1", "Cal2"}
  repeat with theCurrentValue in theCalendars
	tell calendar theCurrentValue
	  set theEvents to every event
	  repeat with theCurrentEvent in theEvents
	    tell theCurrentEvent
	      if not (exists sound alarm of theCurrentEvent) then
		   make new sound alarm at end /
		   with properties {trigger interval:-15}
		  end if
	    end tell
	  end repeat
	end tell
  end repeat
end tell

That basically means it won’t add another sound alarm if the entry already has one. Much handier. In fact, you could just take that script and have it run every few hours (either cron’d or via iCal), and not have to worry about the iTunes Sync script.

My biggest gripe with the iPhone thus far has really been a gripe with iCal. Namely, that there’s not an easy way to add alarms to subscribed calendars. I know that sounds like a silly gripe, but let me set the stage.

My main calendaring info is in Google Calendar, like a lot of folks. This is great because I can access my calendar from anywhere, on any computer, most cell phones, etc. It gives me a central way to maintain a calendar and have access to it pretty much all the time. I subscribe to my Google Calendar in iCal on my Mac, which gives me native calendaring (one-way, at least) that’s always up-to-date with the data in the Google cloud. It’s nice.

Taking it one step further, I use SyncMyCal to push my Outlook calendar to my Google Calendar as well. (I would use the normal Google Calendar Sync application, but it only syncs with the primary calendar, and I’d rather keep my personal calendar and work calendar separate.) So, every day, before I leave the office, I click a little sync button and it pushes my Outlook info up to Google Calendar. Again, one-way sync, but it’s one-way from my primary source, so I’m not worried about it.

That means I’ve got my personal and work calendars all centrally located on Google Calendar, accessible from pretty much anywhere. Including my primary machine of my Mac, where iCal subscribes to all of my various calendars. It’s a wonderful system.

Except one thing. iCal doesn’t allow you to set alarms on subscribed calendars. At least not through the interface. That makes this wonderful sync system decidedly less useful. See, between my MacBook and my iPhone, I’m pretty much covered. One is with me most of the time. If I had alarms on my calendars, then I’d pretty much have a perfect setup.

It worked incredibly well with my Motorola Q (and The Missing Sync from Mark/Space), which would import all of the calendar items from iCal, and set default alarms on them on the Q. Beautiful.

Not so much on the iPhone. For a couple of months, I’ve just dealt with the fact that using Google Calendar put me in the middle of the two supported options: using iCal and using Exchange (which became available with the 2.0 firmware). I could see the calendar events on my iPhone, but they were never going to make that nice “bleep bleep” sound and let me know that I had a meeting or I had to be somewhere in a few minutes. It’s something I had taken for granted with previous smartphones, but just chalked up to a deficiency in the early years of the iPhone.

Except I finally got fed up enough to do some digging into AppleScript and found some pointers to adding an alarm to an event. I figured why not give it a shot on subscribed calendars? Maybe I could add some alarms to my subscribed calendars?

After poking around and playing with AppleScript (something brand new to me, I got this working):

tell application "iCal"
	set theCalendars to {"Subscribed 1", "Subscribed 2"}
	repeat with theCurrentValue in theCalendars
		tell calendar theCurrentValue
			set theEvents to every event
			repeat with theCurrentEvent in theEvents
				tell theCurrentEvent
					make new sound alarm at end with properties {trigger interval:-15}
				end tell
			end repeat
		end tell
	end repeat
end tell

Basically, we grab our two subscribed calendars (those are placeholder names, replace with your own subscribed calendar names), go through each entry and add a sound alarm 15 minutes before the event. It takes maybe 10 or 15 seconds to go through both of my calendars, but lo! I end up with alarms both in iCal and on the iPhone!

Bingo. Exactly what I need. I’m sure there’s something more elegant, but this worked for me.

The next issue, of course, was a “race condition” of sorts. My calendars update themselves periodically. If they updated before I sync with my iPhone, the alarms would be gone. How could I resolve that?

How about another AppleScript? I did a bit more googling, and of course, there’s a nice way to sync your iPhone (or iPod), via AppleScript. Why not combine both scripts and drop it into the iTunes script directory? That’s a brilliant idea!

tell application "iCal"
	set theCalendars to {"Sub1", "Sub2"}
	repeat with theCurrentValue in theCalendars
		tell calendar theCurrentValue
			set theEvents to every event
			repeat with theCurrentEvent in theEvents
				tell theCurrentEvent
					make new sound alarm at end with properties {trigger interval:-15}
				end tell
			end repeat
		end tell
	end repeat
end tell

tell application "iTunes"
	repeat with s in sources
		if (kind of s is iPod) then update s
	end repeat
end tell

Now, when I’m about to leave the house, I just do this:

iTunes Sync

That’s it. All of my calendar items, from Google Calendar, sync’d to my iPhone with alarms. It’s a beautiful thing.

And I wish nothing more than for iCal to render it useless my having a “add default alarm to subscribed calendar” checkbox.

Apr 28

iPhone!

Posted by Ryan Toohil in Apple, General, iPhone, iPod

iPhone

My iPhone is coming! My iPhone is coming!

I’ve meant to use Skitch for a while, and finally got around to using it today. It’s pretty cool. For instance, you can do a search for “phpbb is a piece” and find some fun links:

google results

Then, if you want, you can do some fun stuff to it. Like add some comments:

google results with some color

Tada!

Awesome. Takes about 2 seconds.

Mar 17

Pimp Me A Mac App

Posted by Ryan Toohil in Apple, Mac

I wanna buy a new Mac app.

Things I’m considering:

  • Coda — The all-in-one web dev app is pretty cool, good looking, and I’ve used the demo to build a couple of pages. It’s nice. It’s also expensive. It’d be a no brainer at sub $50. I’m close to buying it when it’s discounted at $79. It’s hard to pull the trigger at $99.
  • Twitterrific — Almost a no brainer at $15, but all it does is remove ads and that just seems kinda wasteful to me.
  • Warcraft 3 — I just kind of want to play an old school RTS like Warcraft or Starcraft.

Sell me on an app or a game. Maybe I’ll buy it.