drnut Posted April 5 Posted April 5 It feels like a very stupid question, but after searching 2 hours, it is still not working. I created an empty Workflow with a Script Filter. I defined a keyword. In the script, I read the argument that follows the keyword and just echo it. When I run the script, the keyword is recognized, but as soon as I continue typing (a blank after the keyword), Alfred switches to default results, so my variable is never being passed. Hitting Enter after the keyword behaves in the same way. Could someone please help me out?
zeitlings Posted April 6 Posted April 6 The script filter expects a specific JSON object as a result that contains information about what to display. Instead of echoing the argument directly, you have to wrap it in this format if you want it to "see" what you typed. Otherwise Alfred will jump to the default fallback because it doesn't know what to do. There is a script filter example under the "getting started" section when creating a new workflow that lets you inspect the format. In short, you would want to do something like this: local input="placeholder" [[ ! -z "$1" ]] && input="$1" cat << EOB {"items": [ { "title": "$input", "subtitle": "$input", "arg": "$input" } ]} EOB vitor 1
drnut Posted April 6 Author Posted April 6 (edited) Thanks for your answer, but it doesn't solve my problem. I tried another test by using python this time. Same behavior. So I think it has nothing to do with the scripting language. I'd also expect that it is a tiny stupid thing, that I'm doing wrong. Btw, I did a reset on all Alfred configurations and had the same behavior. Please have a look at the attached files to see everything in detail. Behavior when executing workflow Input Output Edited April 6 by drnut
Andrew Posted April 6 Posted April 6 @drnut Take another read of @zeitlings reply, as this tells you everything you need if you want to use the Script Filter. If you don't want to return additional results into Alfred and just want to run a script with an argument, perhaps what you're looking for is: Keyword -> Run Script -> Large Type
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