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.
2 comments:
I use your AppleScript (Thanks), but replaced step 2 and 3 by a simple crontab entry.
In Terminal, type 'crontab -e' and add the line:
55 * * * * osascript /Users/ben/scripts/isync.scpt
This line executes the AppleScript every hour (5 minutes before top of the hour.
Ben
Thank you, very useful.
Post a Comment