RasmusMalver Posted August 17 Share Posted August 17 Hello, I apologize if this is obvious, but I've spent a lot of time, looking for an answer. What I want: When writin `ai` in Alfred, I want Adobe Illustrator. I have a list of templates, that I want to be able to select, using an argument. E.g.: `ai 1920` should open `~/templates/1920.ait`, `ai 1080` should open `~/templates/1080.ait` and so on. How I've tried to do it: Python3 was my first port of call. But I can't find any documentation for python3 and Alfred 5. Everything seems to be from earlier versions. I then tried a list filter. But it keeps searching, instead of accepting my argument. Can anybody point me in the right direction, both on using python, and on prioritizing workflows over search? Link to comment
vitor Posted August 18 Share Posted August 18 You can use Python with any object that takes a script, like a Run Script Action. But you don’t need code at all. Connect a Keyword Input with default settings to an Open File Action set to open ~/templates/{query}.ait and you’re done. Vero and sepulchra 2 Link to comment
sepulchra Posted August 18 Share Posted August 18 (edited) @vitor this is a great example of how simple and powerful this app is. I have other workflows that have file paths with variables as part of the path but I never thought to do this. What a great idea. Edited August 18 by sepulchra Link to comment
RasmusMalver Posted Friday at 11:59 PM Author Share Posted Friday at 11:59 PM (edited) On 8/18/2024 at 4:20 AM, vitor said: You can use Python with any object that takes a script, like a Run Script Action. But you don’t need code at all. Connect a Keyword Input with default settings to an Open File Action set to open ~/templates/{query}.ait and you’re done. Thank you. That does work, and I can open the file with the script, but then I loose the list of choices. Is there a way to keep them? My script, if anybody needs something similar: import sys import os query = "{query}".lower() app = "/Applications/Adobe Illustrator 2024/Adobe Illustrator.app" lookup = {"1080":"RM_1080.ait", "1920":"RM_1920.ait", "A3":"RM_A3.ait", "A4":"RM_A4.ait", "A5":"RM_A5.ait", "A6":"RM_A6.ait", "A7":"RM_A7.ait", "so":"RM_SoMe.ai", "portrait":"RM_Thumbnail_Portrait.ait", "wallpaper":"RM_Wallpaper.ai", "icon":"RM_icon.ait"} if query.strip() == "" or query not in lookup: os.system(f"open '{app}'") else: os.system(f"open -a '{app}' '/Users/RM/Illustrator-templates/{lookup[query]}'") Edited Saturday at 12:00 AM by RasmusMalver Forgot the screenshot Link to comment
vitor Posted Saturday at 12:03 AM Share Posted Saturday at 12:03 AM Always prefer with input as argv over with input as {query}. As for the choices, keep the List Filter. But A4 is a Title, and RM_A4.ait is an argument on that same item. The logic is the same. Link to comment
RasmusMalver Posted Saturday at 12:44 AM Author Share Posted Saturday at 12:44 AM 38 minutes ago, vitor said: Always prefer with input as argv over with input as {query}. As for the choices, keep the List Filter. But A4 is a Title, and RM_A4.ait is an argument on that same item. The logic is the same. Yes, but I'm lazy! I can easily make a python dictionary with aliases and filenames, but it takes minutes to use the Alfred UI to add all the options. Of course I can export, unzip, edit, zip and import, but is there no easier way to add many things to a list filter? Link to comment
vitor Posted Saturday at 12:46 AM Share Posted Saturday at 12:46 AM You can make a CSV and drop it in there. The bottom of the object configuration explains the format. Or use a Script Filter. Link to comment
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