Jump to content
Sign in to follow this  
franzheidl

Test for Workflow Directory with Applescript

Recommended Posts

In Alfred v1, I could test for the location of an extension using Applescript (enclosing a 'do shell script "pwd"' command that returned the POSIX path of the actual location of the extension on the users disk). That required the Alfred v1 Background option to be checked to work.

 

The use case is to locate the extension/workflow on the disk to link/include additional resources like external .scpt files to be run, custom icon files to be displayed in Applescript dialogs, etc.

 

Now I'm trying to do the same thing with Alfred v2, but all I get is an "/" as POSIX path (which is the exact same behaviour as in v1 when the Background option was NOT checked).

 

 

Here's a sample/test extension for v1 which upon keyword "twd" displays an Applescript dialog with the POSIX path to the extension:

 

Test Extension Directory.alfredextension

 

(Try unchecking the Background option and you'll get an "/" only instead"

 

 

Here's a sample test workflow for v2 that tries to accomplish the exact same thing with Applescript but does return an "/" only either. In v2, there is nothing like a Background option for Applescript Workflow modules anymore. I suspect v2 runs an Applescript the exact way like v1 did when the Background option was unchecked (use "twd" to run):

 

Test Workflow Directory with Applescript.alfredworkflow

 

 

 

In v2 however using a shellscript module to do that works just fine (use "twdsh" to run):

 

Test Workflow Directory using sh.alfredworkflow

 

 

To include an extra shellscript module that only does a "pwd" to pass on to my Applescript to get the workflow path seems overkill, especially when additional queries need to be preserved.

 

I'd be truly grateful if you could point out if that's down to the yet incomplete Applescript support in v2 (? - Everything else Applescript runs just fine in v2 so far), if there'll be some option to get the "Background" behaviour back in v2 later on, or if there is another, simpler way to test for the actual full path to the workflow directory from inside an Applescript with v2.

 

 

Share this post


Link to post

Yep, this is coming to AS actions - I just haven't finished them yet, so all run as NSAppleScript. The background option makes them run as osascript in the correct folder, so this will come soon :)

Share this post


Link to post

+1 for getting this option.

 

I had a few goes of trying to run a shell script from AppleScript to return a non root path, but none of them returned anything other than "/".  So logically I can see why but just in case ... has anyone figured out a way (even a convoluted one) of getting the workflow path into an AppleScript?

Share this post


Link to post

This doesn't work yet, since Applescripts run as NSAppleScript only for now, but if you read Andrew's post above Applescript as OsaScript will return to Alfred 2. :-)

I wonder whereabouts this is on the priorities list Andrew?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...