Make your Mac tell the time

When the power goes out and you're faced with a houseful of futilely blinking clocks in desperate need of setting, your Mac can help. Hints reader jsdetwiler figured out a clever way to turn his Mac into a talking clock. When the clocks go out, he can dial his speakers way up and run a little command line script, then move leisurely from room to room, synchronizing all of his clocks to his Mac's time.

To accomplish this yourself, launch Terminal (Applications/Utilities), paste in this code, and press Return:

while [ 1 ];do z=`date +%S`;if [ `expr $z % 5` -eq 0 ];then say `date "+%l %M and %S seconds"`;fi;done

Your Mac will start announcing the time (perhaps after a brief pause). It won't stop until you hit Control-C in Terminal, or simply quit the Terminal app.

The script combines a couple of clever elements. The first is the say command; your Mac will speak anything that follows it. The script also contains a conditional that makes sure the time is read out every five seconds (by checking to see whether the current number of seconds past the minute is evenly divisible by five). Without that five-second check, your Mac would start blurting out the time as fast as it could. It takes about two seconds to read the time and start over, so that'd be 30 times a minute; by making your Mac speak at five-second intervals, you hear only a manageable 12 updates per minute. One other reason this tip works: Your Mac automatically syncs its time to a time server on the Net, so it resets itself when the power comes back.

There are plenty of other ways you could find the right time as you reset your clock—a watch or an iPhone come to mind. But none of them would be as much fun.

Subscribe to the Help Desk Newsletter

Comments