davedelong Posted December 20, 2014 Share Posted December 20, 2014 I'm interested in making a custom workflow that behaves like the following scenario: the user types the keyword "disk" into Alfred the results shows a list of all of the volumes associated with the computer the user selects one of the volumes (ex: "Macintosh HD") and presses "enter" the search field updates to read "disk Macintosh HD" the results update to show a list of options that can be performed on the disk, like "Open in Finder", "Open in Terminal", "Get Info", etc the user selects one of these options and presses "enter" to perform the action I've been poking around in Alfred, and I know how to do steps 1-3 and 5-6. What I don't know is how to tie them together. How can I make it so that selecting one alternative updates the UI to present more alternatives? Link to comment
Florian Posted December 20, 2014 Share Posted December 20, 2014 What have you done so far? Can you send your workflow over? I believe this has to be a Script Filter and use "autocomplete". This script filter would return the list of all volumes as long as the query is empty and the details for a disk when there is a query. Link to comment
rice.shawn Posted December 20, 2014 Share Posted December 20, 2014 There are a bunch of ways to do this. One way that was developed a while ago can be read about in this thread. But it seems like that method would be overkill. To take advantage of the "autocomplete" that Florian mentioned, you'd do something like this: $query = "{query}"; $options = [ 'Macintosh HD', 'External HD' ]; print "<?xml version='1.0' encoding='UTF-8'?>\n"; print "<items>\n"; if ( ! in_array( $query, $options ) ) { foreach( $options as $option ) : print "<item autocomplete='{$option}' valid='no'>"; print "<title>{$option}</title>"; print "</item>"; endforeach; } else { $actions = [ "Open in Finder", "Open in Terminal", "Get Info" ]; foreach( $actions as $action ) : print "<item arg='{$action}--{$query}' valid='yes'>"; print "<title>{$query}: {$action}</title>"; print "</item>"; endforeach; } print "</items>\n"; So that's just a simple script filter. When you pass it to the action, you'll want to make sure that you split the query passed, because the query will be in the form of: {$action}--{$query} Link to comment
smarg19 Posted December 21, 2014 Share Posted December 21, 2014 Alternatively, you can use External Triggers to link two Script Filters together. Filter 1 connects to an AppleScript node that calls the External Trigger and passes the arg. Filter 2 is triggered by the external trigger and receives the arg as the query. My Pandoctor workflow (see sig) uses this method a lot. Link to comment
deanishe Posted December 22, 2014 Share Posted December 22, 2014 It's a personal thing, but I think the External Trigger method is a bit sucky. It's totally one-way. After a trigger is called, there's no way back to the previous "screen" without closing and re-opening Alfred and entering the previous query again. Having a massive query isn't ideal, either, but you can navigate back up again much more easily. Link to comment
smarg19 Posted December 24, 2014 Share Posted December 24, 2014 It's a personal thing, but I think the External Trigger method is a bit sucky. It's totally one-way. After a trigger is called, there's no way back to the previous "screen" without closing and re-opening Alfred and entering the previous query again. Having a massive query isn't ideal, either, but you can navigate back up again much more easily. True enough, but sometimes one way is all that's needed. Of course, Andrew could upgrade this facet of workflows in the future (here's to hoping). 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