andy4222 Posted September 22, 2023 Share Posted September 22, 2023 Hi Alfred community, I'm trying to write a workflow where I want to trigger the workflow by a keyword, let's say `ss`. I want it to have `Argument Required` args, unless I use a modifier key (opt/cmd/shift) and then I can skip this mandate and do something. How can I accomplish this? Right now, I entering a <space> as an arg and the conditional utility to perform a different action. I'm hoping I can change it to a modifier key Link to comment
vitor Posted September 22, 2023 Share Posted September 22, 2023 For such specific custom behaviour, you’ll need a Script Filter instead. Set the language to /usr/bin/osascript (JavaScript) and use this code: function run(argv) { return JSON.stringify({ items: [{ title: "YOUR TITLE HERE", subtitle: "YOUR SUBTITLE HERE", valid: argv.length > 0, arg: argv[0], mods: { cmd: { valid: true }, alt: { valid: true }, ctrl: { valid: true }, shift: { valid: true } } }]}) } Replace YOUR SUBTITLE HERE and YOUR SUBTITLE HERE with whatever you want. andy4222 1 Link to comment
andy4222 Posted September 22, 2023 Author Share Posted September 22, 2023 (edited) @vitor I tried this and it works well. The only thing is now when I press `ss`, the resultant item `Search Splunk for...` always shows up at the end of the Alfred results despite my using it many times. Is there anything wrong I'm doing here? Alfred's most frequently used item feature works well for everything else for me. Second, I enable the `Alfred filters results` for this script filter and when I would type something as an arg, Alfred would move away from this script filter and go back to my fallback results. Is that because what I'm typing cannot be found in the script results list? e.g., when I typed `ABC` this string is not in the results returns by the filter (since we only have `Search Splunk....`. Trying to understand if it's working that way. Third, I searched a bit but could not find that we can change this setting via this code. Are these fields/options documented anywhere on Alfred's website? Edited September 22, 2023 by andy4222 Link to comment
vitor Posted September 22, 2023 Share Posted September 22, 2023 1 hour ago, andy4222 said: always shows up at the end of the Alfred results despite my using it many times. Add a uid: "search_splunk", line above the title one. The value of uid can be anything, it just needs to be static. 1 hour ago, andy4222 said: I enable the `Alfred filters results` for this script filter You can’t do that because you’ll no longer be able to set the custom argument. 1 hour ago, andy4222 said: Are these fields/options documented anywhere on Alfred's website? Script Filter JSON Format. andy4222 1 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