sveinbjornt / Platypus

Create native Mac applications from command line scripts.
https://sveinbjorn.org/platypus
BSD 3-Clause "New" or "Revised" License
2.83k stars 171 forks source link

Strange behaviour when dragging files on app icon #106

Open NicolasReibnitz opened 6 years ago

NicolasReibnitz commented 6 years ago

Hi!

I recognized some issues when starting apps built with Platypus by dragging files onto the app icon. With certain files the underlying script runs twice and some files get not passed to the script at all. When the script runs from terminal all is fine. When I start the app first by opening the app and then drag the files into the text window it runs fine as well! So it just behaves weird when files get dragged onto the app icon.

I used the latest Platypus version (v5.2) on macOS Sierra (v10.12.6) with these settings here: /usr/local/bin/platypus --droppable --app-icon '/Users/nicolasreibnitz/Downloads/Platypus-5.1/Platypus.app/Contents/Resources/PlatypusDefault.icns' --name 'Testscript' --interface-type 'Text Window' --interpreter '/bin/bash' --uniform-type-identifiers 'public.item|public.folder' '/Users/nicolasreibnitz/Documents/git/shell-script-app-template/testscript.sh'

This is the script for testing: screen shot 2017-12-30 at 22 49 31

Here is the output in terminal (expected result): screen shot 2017-12-30 at 22 52 47

The output with Platypus (all in all only 12 files were passed and it ran twice): screen shot 2017-12-30 at 22 54 43

And finally the output when files were dragged in the text window (all good with expected results.): screen shot 2017-12-30 at 22 56 44

Different file combinations yield different results and which files were clicked on when dragging seems to change the output as well. All files were recognized, even the three that were not processed in the first Platypus screenshot. But I guess you get the point without me listing all combinations I tried. Oh, and it's not the spaces in the filenames. I checked that as well.

Finally, here is the app in question. Testscript.app.zip

In any case: I love Platypus! And I know for a fact that this behaviour is rather new. But using older versions of Platypus didn't help. Maybe it's an OS X issue?

Thanks in advance!

sveinbjornt commented 6 years ago

This is a really, really annoying issue with OS X Launch Services. Basically, when files are dropped on an app or opened with an app via the Finder, the application receives an OpenDocument Apple Event. However, it may receive one or more OpenDocument AEvents if multiple files are opened/dropped on the icon, with no way to know how many. As it stands, Platypus triggers one execution of the script for each event :/.

Coincidentally, I've been struggling with this issue in another project and am looking for an elegant solution. Will implement it in Platypus if I find one.

NicolasReibnitz commented 6 years ago

Ah, thank you. I thought it might be me. Would be great if this can be solved. Looking forward! Thanks again.

laowantong commented 2 years ago

Same problem here. I thought I was crazy!