Palm Synch-n-Quit 2.0
by Joseph C. Slater and Arno Wouters

This script runs the Palm Serial Port Monitor (SPM), then quits it after a the Conduit Manager quits so you don't have to remember to quit it and get the nasty crash on wake problem. If you follow the instructions, you can then just hit an F-key, hit synch on your Palm, and not worry about remembering to quit or having to go to a menu to select a script that quits it. This script is set for a 15 second delay, meaning you have 15 seconds once you have the SPM running to get the Palm in position and tell it to synch.

The actual script is shown below.  If you want to change this code, or any of the delays,  select "Save As Run-Only..." from the file menu. Then name it and, from the pop-up menu below the entered file name, select "classic applet".  These are necessary only if you want run it using an F-key. You may not need precisely these options otherwise. Put it (the script) some place where you won't accidentally delete it. Use the keyboard control panel to assign a function key to it.

NEW IN VERSION 2.0:
It no longer requires the Serial Port Monitor to be located in a pre-defined location and uses Eric Grant's sleep commands osax to avoid hogging the CPU. You need to install a copy of install  Eric Grant's sleep commands osax <http://home.earthlink.net/~eagrant/>. Beta 6 has been included for completeness. To install Sleep Commands, drag the file named "Sleep Commands" onto your system folder.

No warrantee is expressed or implied. This code may cause all sorts of nasty things to happen, but I'm running it myself, so... probably not. If I'm wrong, please fix it and send me a copy. You are free to distribute this code, with documentation, as long as it's in its original form. If you change it, document your changes so I don't take the blame.

Good luck,
Joe Slater

Special thanks to Arno Wouters, who re-wrote this script in it's current version,  and the other guy whose improvements I lost before I could incorporate them (and whose name I lost).

Download:

This download has been removed pending obtaining permission from the author of the Sleep Commands, or my revising to the previous code not using the Sleep Commands.  The Sleep Commands was included without the express permission of its author, Eric Grant, in violation of copyright law. I don't think he's really mad, but it's up to him, not me, to determine whether or not I may distribute his code (there are often good reasons for denying even the distribution of freeware code, in this case it's most likely because it's beta).
You can download version 1, and version 2 without the Sleep Commands, here.
This is a MacBinary Suffit File. You'll need Stufit Expander 5.5 to expand it. Just drag the downloaded file onto Stuffit Expander.
 

Here is the actual script for 2.0:

try
 tell application "Finder" to ¬
  set appPath to application file id "Gld2" as string
 launch application appPath

on error number errNum
 if (errNum is equal to -1728) then
  error "Application \" Serial Port Monitor\" does not exist on your system."
 else
  error "An unexpected error occured:  " & errNum
 end if
end try

sleep for 15

sleep while running application "Conduit Manager"

quit application appPath
 

Frequently Asked Questions:
Q: I downloaded this but the one with the sleep commands died on the sleep-while statement (unexpected "while" -- how do I tell it to look for sleep commands) and the version without the sleep commands just seemed to hang.

You need to drag the sleep commands file onto your system folder and have it put where it wants to be put (Apple magic). Then the while command should work. You may need to reboot.
The one that seems to hang may actually be working. It will run for 15-30 sec before quitting if nothing happens on the serial port. When testing your script, open your Palm folder and watch to see is the Serial Port Monitor application goes grey, indicating that the applescript launched it.
Q: How do I see if the script is working?
Without your Palm, run the script. The Serial Port Monitor Icon should go gray for 15 seconds, then go back to normal. The script just turns it on and off.
Q: I downloaded your script but I cannot get anything to change as a result of running it. I am not too familiar with scripts so I may be doing something wrong. I have tried both V1 and V2 (with the sleep commands installed in scripting extensions). I click on the script icon and it seems to run but I see no sign of action from serial port monitor and syncs do not start when I try to initiate them during the script run. Am I missing something?
You need to set HotSynch manager to use the IRPort. It's also helpful if you open the Infrared control panel on your mac so you can see the activity when a connection occurs. Serial port monitor is a background application, so you won't see it launch. However, you should see it's icon go grey when you run the applescript.
Q: Synching seems to be unreliable. What can I do?
I haven't the foggiest. This is not the script. In fact, I have worse luck Synching than most of you! I find that rebuilding the desktop sometimes seems to help, but I don't think it's related. Maybe it's the reboot that does the work. From what I recall, the more extensions you have loaded, the worse the luck. One thing you can do is open the Infrared control panel and watch what's happening with the IRPort. It won't help the Synch, but it will give you some idea of what may be wrong, and it gives you something to do while the Synch is failing.;)