This tip is courtesy of MacOSXHints.com

I have modified it in a place or three.

Have you noticed that when you launch iCal, it will keep the current 
date in its dock icon. But, when you quit, it will not later update 
that date or if you do a restart, its date returns to July 4? Would you 
like it to always show the current date?

This little tip will enable iCal to always show the current date in the 
dock icon.

Requirements:
Mac OS-X (preferably the latest greatest version)
Apple's iCal application available at http://www.apple.com/ical/

We are going to get some practice using Terminal to make this work.
While many parts of this can be accomplished without using terminal, 
this will give you a chance to learn how to use some of the parts of 
OS-X that normally you might not think to try out.

Step 1) Getting started.
Start Terminal (it is located in the Utilities folder which is in your 
Applications folder.

Step 2) We are going to create a folder for putting scripts in.
Enter the following commands into the terminal window:

        cd ~/Library  and press the return key  <-- note the ~ character is 
usually in the top left hand side of the keyboard, it is a shift 
character.
        mkdir bin  and press the return key
        ls -la  and press the return key

The window should list everything that is in the Library folder. Pay 
attention to the line that looks like this:

                drwxr-xr-x    3 admin  staff    102 Feb 20 14:55 bin

The part you are looking for is the front part; it should read 
drwxr-xr-x  (These are called the file permissions)
If for some reason does not, then type the following:

        sudo chmod a+x bin  and press the return key

You will be asked for your password enter it and press the return key. 
Enter the ls -la command again to verify that it is okay.

Step 3) We are going to create the script that tells iCal to update its 
dock icon date.
Enter the following commands into the terminal window:

        cd bin  and press the return key
        pico fix-ical  and press the return key

A text editor will open up. Enter the following (you can copy and paste 
from this message)

#!/bin/sh
#
# Name: fix-ical
# Launches ical and immediately quits to aid
# in fixing the stuck dock icon
#
# Save this script as "fix-ical" in your ~/Library/bin
# change permissions to executable
# Set to run from a cron task
#
# the script is set to pause 10 secs after launching ical
# this can be adjusted to taste per your machine

/Applications/iCal.app/Contents/MacOS/iCal &
sleep 10
ps -ax | grep iCal | grep -v grep | awk '{print $1}' | xargs kill -9

Now hold the control key and type o (cntl+o) At the bottom of the 
editor it will say 'File Name to write: fix-ical'. Just press the 
return key. Now hold the control key down and and type x (cntrl+x). You 
will exit the editor.  Type the following commands:

        ls -la  and press the return key

Look at the listing. for fix-ical. You will notice there are no 'x's 
listed in the permissions part. We need to change that.

        chmod a+x fix-ical  and press the return key
        ls -la  and press the return key and this time it will look like:

                -rwxr-xr-x   1 admin  staff   462 Feb 20 16:24 fix-ical

which is what we want.

Step 4) We need to have this script run everyday (I am going to have it 
execute at midnight every night). To do that we are going to set it up 
as a task that the OS will run for us every night so that we don't have 
to. This is called a CRON task. Type the following commands:

        cd /etc  and press the return key
        ls -la and press the return key

Notice there is a file called crontab there:

                -r--r--r--   1 root    wheel     395 Feb 20 15:03 crontab

It is owned by someone called "root" who belongs to a group called 
"wheel" and notice that there are no execute permissions. This is how 
it should be. It keeps casual users from mucking around with the 
system. So far so good. We are going to muck around with the file and 
tell the OS to use our script. Type the following:

        sudo pico crontab  and press the return key

You will be asked again for your password. Enter it.
The editor will again start up.

A "stock" cron listing should be something like the following:

# /etc/crontab
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hour    mday    month   wday    who     command
#
#*/5    *       *       *       *       root    /usr/libexec/atrun
#
# Run daily/weekly/monthly jobs.
15      3       *       *       *       root    periodic daily
30      4       *       *       6       root    periodic weekly
30      5       1       *       *       root    periodic monthly


Move the cursor to the end of this and enter the following:

# Update iCal to show correct date
0       0       *       *       *       root    cd 
/Users/admin/Library/bin/ ; open ./fix-ical
#

(again you can copy and paste if you are not a good typist. Those are 
tabs between the entries but you can enter spaces. Be careful that you 
copy this exactly as you see it.)

Now hold the control key and type o (cntl+o) , then hold the control 
key down and and type x (cntrl+x). You will exit the editor.

Tonight at midnight*** iCal will start up for 10 seconds then quit. 
Tomorrow when you get up (or if you are still up tonight) you will see 
the current date in the iCal's dock icon.

Enjoy.

Notes:

* CRON is a program that does not have to be restarted in-order for 
changes like we have made to take effect.

*** CRON will not have run if the computer is turned off, or if the 
hard disk has been put to sleep! If you do shut the machine down or set 
it to go to sleep, you must adjust the CRON times to run when the 
machine is active.

                        Jerry




        



| The next meeting of the Louisville Computer Society will
| be February 25. The LCS Web page is <http://www.kymac.org>.


Reply via email to