Jump to content
CarlosNZ

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.

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post

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.

Share this post


Link to post

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 :)

Share this post


Link to post

Okay, I think I've got something worked out. When it's working, it's going to be pretty neat I think. Thanks for pointing me in the right direction, simonbs. [Edit: and aiyo! ;) ]

Edited by CarlosNZ

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...