Applescript your Calendar Colours


A more interesting way to solve this problem is by using randomly generated colours. To do this, we'll need to write a quick, easy AppleScript.
If you are using Mac OS X 10.3 or later, simply click this link to automatically open up Script Editor with a window containing the script you need.
If you are using an older version of Mac OS X, load up Script Editor (from /Applications/Applescript) and paste the following script into the window that appears:
tell application "iCal"
set calnum to (count every calendar)
repeat with currentnum from 1 to calnum
set calcolour to (the color of every calendar)
set red to random number 65535
set green to random number 65535
set blue to random number 65535
repeat until calcolour does not contain {{red, green, blue}}
end repeat
set red to random number 65535
set green to random number 65535
set blue to random number 65535
set the color of calendar currentnum to {red, green, blue}
end repeat
end tell
Now all you need to do is click Compile (the hammer icon) and then click Run. iCal will load up and each of your calendars will be assigned a new colour. It doesn't work perfectly - sometimes two colours will be very similar. However it is much more fun than going through each calendar individually and this is a great example of just how powerful AppleScript can be.
Get Custom Audio or Visual Alerts
Whenever Mac OS X wants to get your attention, it plays an alert sound. For example it does this when a dialog box appears, when you receive an email and as an iCal alarm. Your Mac comes with a nice set of alert sounds, but after a while they may get a bit boring.
You can add your own alert sounds by placing audio files in a certain folder. Before you do that however, you will need to convert your sound file to the AIFF format using iTunes. Open up iTunes and choose Preferences from the iTunes menu. In the Advanced section, click on the Importing tab and choose AIFF encoder from the pop-up menu. Click OK.
![]()

If the audio file you want to use is in iTunes, select it and then click on the Advanced menu. In here choose Convert selection to AIFF. If you audio file is somewhere else, hold Option while clicking on the Advanced menu and choose Convert to AIFF. This will bring up a dialog that will allow you to navigate to your audio file. Once the file is done converting, go back to the preferences and change the "Import Using" pop-up menu back to AAC.
Now we have to get this file to show up in the Alerts list in System Preferences, Mail and iCal. Open up your user folder, look in the Library for a folder called Sounds and drag the sound here from iTunes. Your new alert should now be in the list in the Sounds section of System Preferences.
Make your alerts visual
An alternative to the audio alert is a visual alert, which is basically a screen flash. You can turn this on in the Universal Access section of System Preferences, under the Hearing tab. This will flash the screen as well as playing an alert sound. If you want to get rid of the sound and just have the flash, go to the Sounds section of System Preferences and move the Alert Volume Slider all the way to the left.

Annoyingly, this will also mute the feedback you get when the volume is changed and the interface sound effects (like when you move something to the trash). If you're fine with this then use the method above. However if you still want these other sound effects, there is a better (but more complicated) solution.
Mac OS X will also flash the screen if for some reason it is unable to play the selected audio alert. To make this happen, open up TextEdit and press Command-Shift-T to convert the document to plain text. Save this empty file as Flash.aiff in the sounds folder inside your Library. If a dialog asks you which extension to use, choose .aiff.

Now if you look in your alerts list in System Preferences there will be an alert called Flash that does exactly that - flash the screen. This is because Flash.aiff isn't really a sound file. When your Mac tries to play it and can't, it flashes the screen instead to make sure you still see an alert.
Peek inside Mac OS X Packages
Packages are great because they allow the developer to store all the important related files inside the application. They are also great because they make it very easy to tinker with the way applications work.
To view or edit a package's contents, Control-click (or Right-click) on the application and select Show Package Contents from the context menu. This will bring up a finder window containing a folder named Contents. Inside here is the actual package contents.
The following are a few examples of what you can do inside Mac OS X packages.
Warning: It is a good idea to keep a backup of any file you modify. To do this, just Option-drag the file to copy it to a safe place before making any changes to the original.
1. Change Unexpectedly Quit message
With some tinkering it is possible to customize Mac OS X alert messages and dialog box text. For a bit of fun, you can change the message that appears when an application crashes to something more humorous.
Open up your hard drive and navigate to /System/Library/CoreServices. Find the Crash Reporter package and open it by Control-clicking (or right clicking) and choosing Show Package Contents.
In the window that appears, navigate to Contents/Resources/English.lproj and find Localizable.strings. Copy it to your Desktop and open it up in TextEdit. Near the bottom of the file you will see the line -
/* Unexpectedly quit dialog */
In the lines that follow this it is fairly obvious how to change the message. The symbol "%@" will make the message display the crashed Application's name, and "\n" will make a line break. Save the file and then copy it back to the package to replace the old version. You will have to enter your administrator password.

2. Change an application's default icon
You probably know how to change an application's icon by opening up its Get Info window (Command-I), clicking on the icon and pasting a new one over it. You can use the Cut tool (Command-X) to remove this icon and return to the default. To change this default icon, you have to delve into the package. The icon file is stored in the Resources folder within the package contents, and normally has the same name as the application with the .icns extension. You can replace this file with any other icon file, whether it is downloaded from the Internet or taken from another application.
If you dislike the way the iCal icon always displays the date as July 17 when it isn't open, there is an alternative icon inside the iCal package. If you look inside the Resources folder you will find two icons - App.icns and App-empty.icns. To change which one iCal uses, simply rename App.icns something like AppJul17.icns and make a duplicate of App-empty.icns named App.icns.
Some people also dislike the iTunes 7 icon. This Mac OS X Hints article describes how to change it back to the one used in iTunes 6.
3. Open help files in a Web browser
Anyone who has ever used the Mac OS X help browser will admit that it is a little on the slow side. Annoyingly, it also lacks a Save command, meaning you have to go through the slow process of loading it up and finding what you want every time. Luckily, the help pages are just HTML files stored away inside the application's package. This means you can open them up in Safari, which is much quicker for browsing and allows you to save bookmarks and Save pages.
For example, to open up the iPhoto help, open up the iPhoto package in your Applications folder. Then navigate to the English.lproj folder inside the Resources folder. Here you'll find a folder called iPhoto Help with a file named iPhoto Help.htm inside. Double-click on this file to open it up in Safari.

Annoyingly, every now and again a link will open up in Help Viewer, but generally you can browse the help files from within Safari.
Things like Airport, Applescript, Bluetooth, iPod and Mac OS X itself don't have an Application package to store the help files in, so these are located in the Library folder. To find them, go to your Hard drive and look inside Library/Documentation/Help. Each of the .help files in here is a package.
4. Change Text Clipping Behaviour

5. Customize System Preferences
All the System Preferences panes are grouped into five categories - Personal, Hardware, Internet and Network, System and Other. It is quite easy to change these category names by going inside the System Preferences package, which is in the Applications folder. Inside it, navigate to the English.lproj folder inside the Resources folder. In here, find a file named NSPrefPaneGroups.strings and drag it to your desktop. Now open this file up in TextEdit and you'll see the following lines:
"personal" = "Personal";
"digitalHub" = "Digital Hub";
"hardware" = "Hardware";
"net" = "Internet & Network";
"system" = "System";
"addons" = "Other";
Don't change the words on the left, these are the ones used by System Preferences. You can change the words on the right. These are the ones displayed in the System Preferences window. Just make sure you don't delete any quotes or semicolons. Also, ignore the "Digital Hub" entry. This isn't used anymore and is probably just left over from a previous version of the operating system.
Now save the file and drag it back to the English.lproj folder from the Desktop. You will have to Authenticate this action with your administrator password.
6. Modify iCal alarm message

Merge Two iCal Calendars
If you start off with two separate calendars it is fairly easy to merge them into one if you later decide to. Luckily you don't need to go through every single event and change the details. You can do them all in one with the export command.
First choose the calendar you want to get rid of. Select it in the calendars list, and go to the File menu and choose Export. Choose any name and location. You aren't going to need this file for very long, so save it somewhere like the desktop so you can easily get to it.
Now you are going to re-import the events into the calendar you are merging them with. Go to the File menu and choose Import. Navigate to the file you saved earlier, and click Import again. In the dialog box that appears, choose the Calendar you want to merge the events into.
If everything went OK and all the events are in one calendar, you can safely delete the other one.
5 Quick iCal Tips

2. If you are really worried about missing an event, set more than one alarm for it. In the info panel for your event click on the word "alarm" and a menu will appear allowing you to add or remove alarms. You can even set alarms to go off after the event, for example if you need to drop someone off and then be reminded go pick them up an hour later.

4. While iPhoto is great for printing pretty calendars, iCal offers a special customized print dialog that gives you much more flexibility in printing your calendars, albeit without the lovely photos. Check out this previous tip for printing To Do lists in iCal.

Printing To Do lists in iCal


Automate your Mac
The first thing to do is to make your Mac turn on by itself. You can set it to do this in the Energy Saver preference pane in System Preferences. Just load it up and click "schedule" and choose a time to start up (and/or shutdown) and on which days you want this. This will also wake up your Mac if it is asleep, but this might not work if you have a password enabled screensaver.



As far a scheduling specific applications goes, you have to use applescripts or automator actions for most of them. If you aren't completely super lazy, it is pretty straightforward to create a workflow in automator that opens up a list of websites, or starts an iTunes playlist going. To get this worklow to be carried out at a certain time, create an event in iCal and set an alarm. As the alarm action, set it to open up the automator file.
However, in some applications you can get the same results without making workflows or scripts. For example, in Firefox you can set multiple websites as your homepage, and all of these will open up when you start Firefox. There are two ways to do this. The first is to create a folder of bookmarks with all the sites you want to load on startup. After creating this folder, go to the Firefox preferences and click "use bookmark" to select the folder. The alternative way is to type in each address into the homepage field with a | (pipe) in between. Be sure to set Firefox to load your homepage on startup using the dropdown menu.

Finally, some applications have built in scheduling capabilities. Microsoft Entourage has tools to set Send and receive schedules that check for email at certain times and Apple's Backup has its own scheduling feature to carry out automatic backups however frequently you want.
You can use all of these features to automate your Mac and make sure that you never have to carry out a tedious task again.
Top iCal Tips
The list of tips includes ways of getting the most out of iCal, organising multiple calendars and scheduling a "dash," a way to prevent procrastination.
Scheduled Startup and Shutdown
This is just about the only way to schedule things without buying other software or using iCal. Basically you can set your computer to come on in the morning on weekdays and go off in the evening for example.
I combine this with a locked screen saver. In the evening I start my "Big Clock" screensaver, then put my mac to sleep. In the morning it wakes up at a specified time, and loads the password dialog box. Then, when no password is typed in, it goes to the screen saver after 30 seconds. This means when I wake up in the morning I can look over and see the time in big bright letter next to me, without them on all night to wake me up.
You can also combine this with an applescript or automator actions to play music or load web pages every morning. After writing the script to do this, set a daily alarm in iCal that loads it every morning, but make sure to make it a minute later than the time your mac wakes up from sleep.



