husk.org / blog. chaff. occasional witterings.

2003-11-05

Neaten iCal

computing 11:30:00

Whilst playing with iCal for the previous entry, I was reminded of one of its most annoying features.

iCal shows all of its views in one window. Like many other Mac OS X apps, this window can show different views, and it resizes for each of them. You can stop the swooshing by resizing the window in each view to be the same size, but it's hard to get this right just by looking.

So, here's a little chunk of AppleScript. Open iCal, pick a view, resize it until you're happy, then run this script:

tell application "iCal"
  -- if you want to bring iCal to the front
  -- activate 

  -- take current window settings
  set curBounds to bounds of window 1 
  -- or set to fixed position
  -- set curBounds to {30, 100, 740, 650}

  switch view to day view
  set bounds of window 1 to curBounds
  switch view to week view
  set bounds of window 1 to curBounds
  switch view to month view
  set bounds of window 1 to curBounds

end tell

(Download script as text, 1k.)

I suppose I should have written it such that it returns to the view that you had initially, but that's only one click anyway, and it's probably not hard to add, if you really care.

The first commented line (-- activate) brings iCal to the front while the script runs. The second commented line (-- set curBounds to {30, 100, 740, 650}) allows you to set a fixed position; in this case, it's about right for a 1024x768 display with the info drawer open on the right. If you like, remove the -- from in front of either line to change the way the script works.

Anyway, share and enjoy. (Edited on Thursday morning to fix some syntax colouring wonks. Oops.)

navigation.