Alfred Script Filters
IntroductionProvides filters that take input directly from Alfred for the purpose of filtering lists or selecting options. DiscussionIn order to use a handler within Alfred, simply call the script with two arguments: the name of the filter to call and the user's query. See the following example for using a bash script to run a filter. Note that backquotes, double quotes, backslashes, and dollar signs should be escaped when providing input this way. Excess escaping can cause problems handling simple characters such as spaces.
Why PHP? This is a [likely temporary] solution to slow feedback from applescript for list filtering. It was found that a simple Hello World script took 90ms to run with osascript, making AppleScript unsuitable for live filtering. Simple script language alternatives such as Python and PHP were put through similar tests. By far Perl was the fastest. However, in order to be useful the language must have an Alfred workflow library and load it efficiently. Perl did not and Python's two options were both shockingly slow. This left PHP which was capable of 60ms response times once the logic was fully implemented. Unfortunately, PHP and AppleScript do not play well together when it comes to platform specifics such as localization. This script will likely be replaced with a compiled Cocoa utility that combines speed and platform suitability. Functions
filterListsToAddTaskA Script Filter input that shows the user's lists in Alfred, allowing a task to be added to a specific list. function filterListsToAddTask( $query) ParametersDiscussionQueries the Wunderlist UI to provide all of the lists into which new tasks can be added. The response is formatted for Alfred to display in a way that allows the user to type their task, then action a specific list to insert the task there. After selecting one of these options, the final query will be a concatenation of the list index and the user's task in a format suitable for addTaskToList:
The user may also select a list by autocompletion or substring matching. If the query text is a substring of any of the list names, the lists will be filtered to show only those that match. The user can action a list item to autocomplete the list name in the following format:
Alternatively, the user can type a colon character indicating that the task is to be entered in the first task matching that substring. The match is case insensitive but is sensitive to accents and other diacritical marks.
getListInfoLoads list info from the cache or reloads it from Wunderlist function getListInfo( $attempts = 0) ParametersReturn Valuean array of associative arrays in the See getWorkflowSettingsLoads the workflow's function getWorkflowSettings() Return ValueAn associative array containing each of the keys from the property list in native PHP data structures. |