Wednesday, August 29, 2007

Easy Access to Windows from OS X


I have Windows XP installed on my Mac on another partition, using Boot Camp. One time saver I use is to have a shortcut to my Windows desktop on my OS X Finder:

It makes it really easy to move files back and forth between the two operating systems. Make sure when you format the partition in Boot Camp initially that you format it as FAT32 or else you won't be able to access the partition from OS X.

"Always Open With" From the Contextual Menu



One little shortcut I use to force a file to always open in a particular application is to right-click (or control-click) and then hold down the option key. The menu will change from "Open With" to "Always Open With" so that whatever application you choose will become the default application, but only for that file. It would be nice if you could change all the files of that type to open in that application but you can't, unless you "Get Info" and select "Change All."

Another interesting thing is that when you hold down the option key "Get Info" changes to "Show Inspector." It does the same thing, but perhaps there are file types that will have different behavior.

Wednesday, August 15, 2007

Making iSync Run Periodically


One annoying thing about iSync is that it can synchronize your contacts and calendar events between your Mac and your phone, but it does not do this automatically.

So I created a setup that automatically syncs my Razr with my Mac:

1. First open up the iSync application and click on your phone (this assumes you've already made your phone connect with your Mac. A menu will appear and click the appropriate boxes so that your phone synchronizes your contacts and calendars.




2. Create a text file named isync.plist inside your home folder:

/Users/joe/Library/LaunchAgents/

The isync.plist file should look like this:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>isync</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/joe/.scripts/isync.pl</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>

This will call our isync.pl perl script every hour (3600 seconds). You can change this to whatever you wish.

3. Open the Terminal and create a hidden directory in your home folder by entering this command:

mkdir ~/.scripts


Next move into this directory by typing:

cd ~/.scripts/


Create a perl file there titled isync.pl:

emacs isync.pl


The perl script should look like this:

#!/usr/bin/perl
use strict;
use warnings;

my $FLAGFILE = "/var/tmp/last-isync-date";
my $age = ((-M $FLAGFILE) || 0) * 24;
print $age;
exit if ($age && $age <>
system("osascript $ENV{HOME}/.scripts/isync.scpt; touch $FLAGFILE");


This script checks when the last time iSync updated your phone was. If it was more than 2 hours ago, then it attempts to run the update AppleScript. You can change the frequency by changing the number 2 to whatever you like in the second to last line.

4. Again in the .scripts directory, create an AppleScript file called isync.scpt:

cd ~/.scripts/
emacs isync.scpt

The AppleScript should look like this:

tell application "iSync"

if not syncing then
synchronize
repeat while syncing
delay 1
end repeat
quit
end if

end tell


That's all there is to it. Good luck and let me know if you have any problems getting this all to work.