Help with Platypus / Cocoa Dialogue...bash rsync script

johnklimeck
Contributor II

Hello,

I have a straight bash script that copies (rsyncs) one folder to another. Using it for OS X home folder for backup and restore.

I have so that it has menus. Essentially backup, restore, etc, options.

User has to select the "Source" and "Target" folders (drag and drop into terminal), and off it goes.

In my efforts to make this simple, our techs still are having issues with scripts / terminal. Would be better and easier as an app.

Have seen Platypus in conjunction with Cocoa Dialogue, in which Platypus will take the script and make it it an OS X app, and Cocoa Dialogue, should allow interaction.

http://sveinbjorn.org/platypus_cocoadialog

Following this, but not getting interaction dialogue windows, (probably has to be specifically scripted, I am guessing).

Or perhaps there is a way to do this is Xcode/Swift.

thx, john

3 REPLIES 3

davidacland
Honored Contributor II

Platypus is a good way to do this. I've used it for a few solutions. Best thing to do is run one of their example scripts first, confirm all is well and work backwards from there.

mm2270
Legendary Contributor III

I've built several apps in Platypus that also use cocoaDialog as part of its UI elements. The tricks to getting this to work are:

  1. Drag cocoaDialog into the Resources section within the Platypus window when setting up the app.
  2. Within the script you need to define the path to cocoaDialog with a variable that you can use when you need to call the application.

Here's one way to do it:

## Get script working directory path
workingDir="$(pwd)"

## Set path to bundled cocoaDialog executable
cdPath="$workingDir/cocoaDialog.app/Contents/MacOS/cocoaDialog"

Then later in the script, whenever you need to use cocoaDialog, you do something like:

"$cdPath" msgbox --title "This is a title" --text "Hello" --button1 OK

Once you build the final app, cocoaDialog.app is copied into the MyApp.app/Contents/Resources/ folder.
Doing it this way it becomes a self contained double clickable app that doesn't require a separate dependency of having cocoaDialog installed somewhere else on the Mac.

thoule
Valued Contributor II

Using Xcode is easier than it may first seem. By using a basic Applescript program that calls shell functions, you can do quite a lot very easily.

I was hoping to write more, but I have just a very basic blog post that may get you started.

I learned from Shane Stanley's AppleScriptObjC