Doug Luce Posted April 11, 2022 Share Posted April 11, 2022 I've a script filter that takes an optional argument. I'll often run it several times in a row with the same argument. I can re-run it by triggering it with the usual hotkey and hitting enter to use the same argument I used last time. However, there's a delay where the choices are enumerated by the script and filtered/displayed by Alfred before the enter key will work. I'd like to do away with that delay and with the need to pop up the list at all. Ideally, instead of the usual Command-8 that I use to run the script filter with arguments, Shift-Command-8 will immediately run my script with the same argument as the latest Command-8 invocation. This can certainly be done by my script, it can store the last argument and use it when a special flag is given. Then I'd use a separate script filter to run it. But I'd like to avoid that. Can Alfred handle this? Link to comment
vitor Posted April 11, 2022 Share Posted April 11, 2022 Welcome @Doug Luce, Hard to say without knowing how your script filter works or how the argument influences the rest of the Workflow. 1 hour ago, Doug Luce said: store the last argument and use it when a special flag is given. That sounds like the simplest solution. You write to a file with the argument as the contents (no code necessary), then later read it back with the other hotkey (one line of /bin/zsh: cat '/path/to/file'). Alternatively, you could go the route of making your list show faster. Why is it slow? Perhaps it’s a fixed list and a List Filter Input would be more appropriate. Or perhaps, instead of generating Alfred’s JSOn every time, you cache it: write it to a file once it’s generated, then on subsequent runs spit out its contents. You could rebuild the cache after every time you action the command. 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