Jump to content

What to do when you want script filter for certain parameters and not others?


Recommended Posts

Hi all,

 

just wondering what people think is the best thing to do in this situation.  I'm working on updating my EggTimer  extension to work nicely with Alfred 2. I've got it working pretty much as in V1, but I'm now trying to incorporate the script feedback capabilities to display running timers in Alfred's window:

 

screenshot20130116at144.png

As you can see, I've used the keyword "stop" here, for the user to select a timer to stop running. However, all the other controls for this workflow start with the keyword "timer" (eg timer repeat, timer 5 Do something.., etc.) and it seems a little off having to create a separate keyword for a script filter. Ideally, you could use "timer stop" to launch this feedback, but there's no way to get a script filter to only respond to a specific argument and behave like a normal script in other circumstances.

 

Things I've tried:

  • Set the regular script keyword and the script filter to the same keyword: "timer". However, this looks a bit weird, and the default "regular" option is not always the top of the list, so I think it's too confusing to work nicely.
  • Make the script filter keyword start with the same keyword, eg. script filter keyword is "timers". This is probably my best bet at this point, but it bothers me a bit because it's inconsistent with the other commands.

What would be really cool is if Alfred could do this:

screenshot20130116at202.png

 

i.e. the argument from a regular keyword input can become the trigger for a subsequent script filter. I wonder what the chances of this happening are?

 

Assuming that won't be happening any time soon, I wonder what other people would recommend for this kind of thing. I'm sure I won't be the only one to have to deal with it. For example, when (if?) @jdfwarrior updates his Alfred+Tasks extension for V2, he'll probably have the same issue, where some commands (eg. "do list" would generate a feedback list) whereas others wouldn't (eg. "do task").

 

Just wondering what y'all think. Cheers.

Link to comment

You could make just one Script Filter that takes an optionally argument.

In the Script Filter you then first check if there is a timer running, If so, then check if the keyword starts with "stop" (or a part of that) and then decide what items to print out...

 

Hope that make sense.

Link to comment
You could make just one Script Filter that takes an optionally argument.

In the Script Filter you then first check if there is a timer running, If so, then check if the keyword starts with "stop" (or a part of that) and then decide what items to print out...

 

Hope that make sense.

 

I think I get what you're saying. And I think I did try something like that. However, the nature of script filters is that they execute the script after every key press (that's how the fancy Google-complete thing works), so in my case it just kept spitting out multiple notifications as the reset of the argument (the ones that aren't "stop") is typed in.

Link to comment
I think I get what you're saying. And I think I did try something like that. However, the nature of script filters is that they execute the script after every key press (that's how the fancy Google-complete thing works), so in my case it just kept spitting out multiple notifications as the reset of the argument (the ones that aren't "stop") is typed in.

It's correct why aiyo says. That's the way to do it. To avoid having multiple notifications shown, you could remove the bash script and the notification action from your workflow and make your script filter display the notifications and only do it when you want it to.

Link to comment

Okay, I see what you're saying about controlling when certain things occur (feedback, notification, etc.), but a Script Filter input will only match commands as they are typed, not when the user has finished and pushes enter. So I don't have a means of letting the user enter "timer 5 Do something", and then pressing ENTER to set it off.

Link to comment

I see. I guess you could return a row when a satisfying pattern is entered (e.g. "timer (min) (message)"). The row would say "Start timer" and have "start-(min)-(message)" as argument, call a script (possibly another dunction in the same script) as action and the newly called function will set the timer with the argument parsed and display a notification. There might be a better way but this is what just what popped into my head :)

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...