The Workflow3 class for Alfred 3¶
Workflow3
supports Alfred 3’s new features.
It is an Alfred 3-only version of Workflow
.
It supports setting Workflow variables and
the more advanced modifiers
supported by Alfred 3.
In order for the feedback mechanism to work correctly, it’s important
to create Item3
and Modifier
objects via the
Workflow3.add_item()
and Item3.add_modifier()
methods
respectively. If you instantiate Item3
or Modifier
objects directly, the current Workflow3
won’t know anything about them, and they won’t be sent to Alfred.
-
class
workflow.workflow3.
Workflow3
(**kwargs)¶ Workflow class that generates Alfred 3 feedback.
-
add_item
(title, subtitle=u'', arg=None, autocomplete=None, valid=False, uid=None, icon=None, icontype=None, type=None, largetext=None, copytext=None)¶ Add an item to be output to Alfred.
See
add_item()
for the main documentation.The key difference is that this method does not support the
modifier_subtitles
argument. Use theadd_modifier()
method instead on the returned item instead.Returns: Alfred feedback item. Return type: Item3
-
getvar
(name, default=None)¶ Return value of workflow variable for
name
ordefault
.Parameters: - name (unicode) – Variable name.
- default (None, optional) – Value to return if variable is unset.
Returns: unicode or
default
: Value of variable if set ordefault
.
-
send_feedback
()¶ Print stored items to console/Alfred as JSON.
-
-
class
workflow.workflow3.
Item3
(title, subtitle=u'', arg=None, autocomplete=None, valid=False, uid=None, icon=None, icontype=None, type=None, largetext=None, copytext=None)¶ Represents a feedback item for Alfred 3.
Generates Alfred-compliant JSON for a single item.
You probably shouldn’t use this class directly, but via
Workflow3.add_item()
. Seeadd_item()
for details of arguments.-
add_modifier
(key, subtitle=None, arg=None, valid=None)¶ Add alternative values for a modifier key.
Parameters: - key (unicode) – Modifier key, e.g.
"cmd"
or"alt"
- subtitle (unicode, optional) – Override item subtitle.
- arg (unicode, optional) – Input for following action.
- valid (bool, optional) – Override item validity.
Returns: Configured
Modifier
.Return type: - key (unicode) – Modifier key, e.g.
-
getvar
(name, default=None)¶ Return value of workflow variable for
name
ordefault
.Parameters: - name (unicode) – Variable name.
- default (None, optional) – Value to return if variable is unset.
Returns: unicode or
default
: Value of variable if set ordefault
.
-
-
class
workflow.workflow3.
Modifier
(key, subtitle=None, arg=None, valid=None)¶ Modify
Item3
values for when specified modifier keys are pressed.Valid modifiers (i.e. values for
key
) are:- cmd
- alt
- shift
- ctrl
- fn
-
arg
¶ unicode
Arg to pass to following action.
-
key
¶ unicode
Modifier key (see above).
-
subtitle
¶ unicode
Override item subtitle.
-
valid
¶ bool
Override item validity.
-
variables
¶ dict
Workflow variables set by this modifier.
-
getvar
(name, default=None)¶ Return value of workflow variable for
name
ordefault
.Parameters: - name (unicode) – Variable name.
- default (None, optional) – Value to return if variable is unset.
Returns: unicode or
default
: Value of variable if set ordefault
.