franzheidl Posted January 13, 2013 Posted January 13, 2013 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.
Andrew Posted January 13, 2013 Posted January 13, 2013 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
franzheidl Posted January 13, 2013 Author Posted January 13, 2013 Thanks so much Andrew, you just took a HUGE weight off my chest.
sylumer Posted January 19, 2013 Posted January 19, 2013 +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?
franzheidl Posted January 19, 2013 Author Posted January 19, 2013 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?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now