Jump to content

How does alfred process keystrokes in arguments?


Recommended Posts

I've noticed that when using a script trigger, alfred will evaluate the entire script from the first character typed in an argument, but the user can continue to type and the script will keep reevaluating.

 

However, I'm trying to build in functionality so that, if on the first keystroke the script will run for a long time, subsequent instances of the script will skip the long processing steps, at least until the initial processing is complete.

 

I've implemented it like so:

 

  1. Check if long_process needs to run, based on a flag in a plist file
  2. If long_process needs to run, set the flag in the plist and start long_process
    1. once long_process is complete, clear the flag
  3. If long_process doesn't need to run, start short_process (to provide feedback to user)

 

However this doesn't work. It appears that short_process will never run, despite multiple keystrokes being entered. How can I make it work, or at least somehow run the long process on a different thread?

Link to comment

I've noticed that when using a script trigger, alfred will evaluate the entire script from the first character typed in an argument, but the user can continue to type and the script will keep reevaluating.

 

However, I'm trying to build in functionality so that, if on the first keystroke the script will run for a long time, subsequent instances of the script will skip the long processing steps, at least until the initial processing is complete.

 

I've implemented it like so:

 

  1. Check if long_process needs to run, based on a flag in a plist file
  2. If long_process needs to run, set the flag in the plist and start long_process
    1. once long_process is complete, clear the flag
  3. If long_process doesn't need to run, start short_process (to provide feedback to user)

 

However this doesn't work. It appears that short_process will never run, despite multiple keystrokes being entered. How can I make it work, or at least somehow run the long process on a different thread?

 

Using the bash sleep command i was able to simulate a long loading script that caught the first character and when the sleep command expired, it triggered again and sent the whole input.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...