Applescript not accepting arRsync sdef commands?

388 views Asked by At

I'm using the opensource GUI frontend for rsync called "arRsync". It works great, but there's no way to automate it.

What I'm trying to do is use Applescript to run a preset (which you define in the Application) using the following simple script:

tell application "arRsync" to runPreset "presetTest1"

The problem is Applescript thinks "runPreset" is a variable, not a command. I've also tried a tell/end-tell variation of the above, no dice. The 'runPreset' command is part of arRsync.sdef

You can find the arRsync project here

I've tried opening up both Info.plist files inside the app and ticking the 'Scriptable' box (or setting it to 'true' for those of you without Property List Editor) but I'm still stuck.

I'm a scripting noob when it comes to Cocoa :p help would be greatly appreciated

1

There are 1 answers

4
outis On BEST ANSWER

The arRsync binary is missing a scripting dictionary. Build from source, first making the following changes:

  1. Edit Info.plist in the project, setting the "Scriptable" option to true.
  2. Fix the project's script dictionary, arRsync.sdef. The code for the runPreset command has one letter too few (command codes must be two FourCCs, or eight characters, long). Add a character to runPreset's code attribute; just about any character will work. If you want, the file can be shortened and simplified by replacing the Standard and Text suites with an include. Back up the orignal file and make a new arRsync.sdef containing:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
    <dictionary title="arRsync Terminology"
                xmlns:xi="http://www.w3.org/2003/XInclude">
      <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" 
                  xpointer="xpointer(/dictionary/suite)"/>
      <suite name="arRsync Suite" code="arRs">
          <command name="runPreset" code="runPPrst">
              <cocoa name="runPreset" class="scriptController"/>
              <direct-parameter type="any"/>
          </command>
      </suite>
    </dictionary>
    

    Alternatively, you could just replace the runPreset command element with the one from above.

  3. Add arRsync.sdef to the "Copy Bundle Resources" phase of the arRsync target
  4. Switch to a Release build ("Blackbeard" is the name for the debug build).
  5. Build it.

That should produce a scriptable version of arRsync. As you've already figured out, you also might need to play with the target SDK.