Any way to “right-click->open” application using application launcher or AppleScript

gatekeeperlaunch-serviceslaunchbarquicksilver

I'm an avid launch service (Quicksilver/Launchbar) user, and have been frequently stymied by Gatekeeper… The default "Open" actions behave like double-clicking an application package, which is insufficient for triggering the dialogue for circumventing Gatekeeper. I used to get around this by asking the respective launcher to "Reveal" the app, and then right clicked it from Finder.

I recently installed Path Finder 6 on my machine to replace Finder/TotalFinder. The problem is, there isn't a way to trigger the "open" right-click action from Path Finder that allows one to circumvent the Gatekeeper block for unsigned applications… So now I have to "Reveal" from QS, and then "Show in Finder" from Path Finder. The ideal situation would just be to figure out exactly what command is being called when you right-click->Open, and implement that as an action in QS or Launchbar… an Apple- or shell-script would be ideal, but I can't figure out what the system command is for that higher level "Open".

Any experience with this out there?

Best Answer

You could create an Automator service with a Run Shell Script action like this:

for f; do
  q=$(xattr -p com.apple.quarantine "$f" 2> /dev/null)
  if [[ $q ]]; then
    xattr -d com.apple.quarantine "$f"
    open "$f"
    xattr -w com.apple.quarantine "$q" "$f"
  else
    open "$f"
  fi
done

Set the input type to files or folders (just folders doesn't seem to include application bundles) and set "pass input" to "as arguments".

Or in Alfred 2 you could add a File Action trigger and connect it to a Run Script action like this:

f="{query}"
q=$(xattr -p com.apple.quarantine "$f" 2> /dev/null)
if [[ $q ]]; then
  xattr -d com.apple.quarantine "$f"
  open "$f"
  xattr -w com.apple.quarantine "$q" "$f"
else
  open "$f"
fi

If you want to keep Gatekeeper enabled but make it ignore some applications, just run something like xattr -d com.apple.quarantine /Applications/SomeApp.app.