Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set the current day to the middle of iCal's week view Apps
What this does: When viewing your iCal calendar by the week, the following Applescript simply changes the iCal setting that says which day of the week to start on, such that the current day is always in the middle of the week view.
tell application "System Events" to set isiCalOpen to count 
  (every process whose creator type is "wrbt")
if (isiCalOpen is 1) then tell application "iCal" to quit
do shell script 
  "defaults write com.apple.ical "first day of week" -int " & 
  ((((weekday of (current date)) as integer) + 3) mod 7)
delay 2
tell application "iCal" to activate
If you'd like to use this script regularly, and you're running 10.4, this code can be saved in ~/Library -> LaunchAgents, named org.ANYNAMEHERE.fixicalview.plist (or anything you want, really). This Launch Agent is set to run the included AppleScript every day at 12:01am.

[robg adds: I tested the script, and it works as described.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[9,760 views]  

Set the current day to the middle of iCal's week view | 11 comments | Create New Account
Click here to return to the 'Set the current day to the middle of iCal's week view' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set the current day to the middle of iCal's week view
Authored by: DotDotComma on Dec 14, '06 08:11:15AM

Nice!

I had to add a forward-slash \ before the inverted commas around "first day of week" in the shell script line (so that it reads thus: \"first day of week\" ) to get Script Editor to handle it properly, but the script worked fine after that.

Mind you, it's Thursday here, so that was the middle day of the week for me even before running the script ... so not a great day to test it!

;o)



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: rusto on Dec 14, '06 09:48:26AM

Note: those are _backwards_ slashes. A forward slash is one of these: /



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: tirerim on Dec 14, '06 11:48:01AM
Note that it's also very easy to change this to make the current day the first day of the week (by eliminating the "+ 3") or the second (by changing it to "+ 1"), or whatever place you feel like, if you want to see more of the future than of the past.

[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: sjwoodman on Dec 14, '06 12:04:57PM

Is it possible to do something similar for the month view? Ideally I'd like to always have the current week in the middle of the month view? Not being an applescript guru I'm not sure where to start in creating such a thing...



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: JonLaliberte on Dec 14, '06 03:04:22PM

I actually changed my own version of this script to use +5 instead of +3 right after I submitted it. +5 makes the current day the second day in the week view which I find is actually more useful than being the middle day.



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: figz on Dec 15, '06 09:38:45AM

If the LaunchAgent doesn't work for you, type the following in the Terminal:

launchctl load ~/Library/LaunchAgent/yourfile.plist

similarly, launchctl unload will undo it.



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: omegawolf on Dec 15, '06 12:13:53PM

I'm feeling like a real mo-ron here... I copied and pasted from the linked code (not from the body of the article), and placed it into the example filename in the ~/Library/LaunchAgents/ directory (which I had to create myself). I logged out & back in just to see that it was working the way it should.. but no dice.

I ran the suggested launchctl command, but it says the script is already loaded. Yet here it is, Friday, and the week view is still starting on Sunday.

Did I need to compile this applescript code? Am I missing something that I just didn't notice in the article?



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: JonLaliberte on Dec 15, '06 01:48:19PM

It will only run if your system is running at 12:01am. If you would like it to run whenever you boot or login, add:
"<key>RunAtLoad</key>
<true/>"

right below the closing array tag "</array>"
This will have the effect of opening iCal when the script runs. You could change the Applescript in the launchd document to remove the "tell application "iCal" to activate" to remove this behavior.



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: Mythologian on Apr 02, '07 09:23:54PM

I changed mine to be +6 so that I have today as the first day of the week view. I loved this feature in Google Calendar and it's actually the feature that kept me from switching over to iCal completely.



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: morespace54 on Apr 03, '07 09:01:51AM

Is this script only works for Tiger?
I'm trying to run it from Script Editor but the script keep saying "Can't make 'Tuesday' into a integer" and stop at line 5... I guess this script doesn't work as a stand-alone. Am I missing something?



[ Reply to This | # ]
Set the current day to the middle of iCal's week view
Authored by: hempKnight on Feb 08, '08 08:07:58AM

thanks, i was about to try and write an applescript to do this same thing!



[ Reply to This | # ]