Search the Community
Showing results for tags 'best practices'.
Found 2 results
I'm just getting started with creating my own workflows and I have a couple questions I haven't found the answers for yet after a bunch of searching, reading and testing. A quick note to begin with, I'm writing this partially as an exercise to improve me proficiency with AppleScript, as frequently painful as it is. It does seem like a good workflow to use it for since its functionality is almost entirely reading information from and sending commands to the iTunes AppleScript Dictionary. JXA is a little further down the to-learn list. 1. What is the proper way (if there is one) to get Alfred's workflow environment variables into an AppleScript file? Right now I'm using the Script Filter to issue the Bash command osascript *file*, I can append a variable to it like "alfred_workflow_data" and read it as an argv or use (do shell script "pwd") to get the workflow path but I haven't found a way to access all of the variables directly. I'm open to ultimately running it as a usr/bin/osascript if that's the best solution, but it's nice to just run the script from my code editor rather than copying and pasting it every time I want to test a change. I have read the pinned post on using environment variables but I'm not sure how to apply it in this context. 2. It looks like the best practice is to use alfred_workflow_data and alfred_workflow_cache where possible but is it appropriate to use the workflow folder for things like included icons or should I be creating a data directory, copying the files there and then using that location when setting icons in a Script Filter? Given that there doesn't appear to be a provided environment variable for the workflow folder path I wasn't sure if that was to discourage using that in the workflow or because it's trivial to determine that path another way. 3. I have a couple of different icons I'm using for different workflow components so I don't want them all to inherit the workflow icon but I also use some of the same icons for multiple trigger objects. If I assign them the same icon I get duplicate *iud*.png files, is there a way to set the path for the icon programmatically so I can set a single image to multiple objects? 4. Along similar lines, does Alfred allow you to use any vector formats for icons? It doesn't seem to accept SVG and it converts vector PDFs to PNG images but I know that some of Alfred's internal workflows use vector code for icons so I thought it was worth asking. If not, is 512px the appropriate resolution? I've seen 128px referenced in older threads but that seems pretty small for uses like icons in the iOS remote app for devices like retina iPads. 5. Finally, is there a good way to assign multiple keywords to the same action? I'd like to trigger my script filter with both itunes and love and I had hoped that using a Keyword object as the input to a script filter would do it but while it still lets me trigger the action object I've linked the script filter to the script filter functionality doesn't work. I've also tried adding an Arg and Vars utility to overwrite the query to the keyword for the Script Filter but I get the same result. I can just duplicate the Script Filter with a different keyword but am trying not to repeat an identical function if I don't need to. Thanks for any help, I really appreciate you taking the time to read over this. The workflow in its current state can be found on GitHub. Alfred 3.6.2  macOS 10.13.5 (17F77) I've customized a lot of my macOS environment but I don't think anything that would affect AppleScript and likely not anything that would affect running osascript commands from /bin/bash.
In many workflows that I've downloaded, I've found that much of the metadata isn't included. It's fairly simple to write the few sentences that make the workflows more meaningful, but the most important one that I've seen is the bundleid, which is often left blank. While not absolutely necessary for the workflow to function on its own, the metadata can help other workflows that interact with the installed workflows in Alfred. Also, it does really help to fill in the website data. If you aren't using github or another page that has more information and lists some other workflows, then it might be best just to link to the forum post in which you release the workflow. Also, this request might just come out of a bit of OCD that I have.