Skip to main content

Full-featured helper library for writing Alfred 2 workflows

Project description

A Python helper library for `Alfred 2 <>`_ Workflow

Alfred Workflows typically take user input, fetch data from the Web or
elsewhere, filter them and display results to the user. **Alfred-Workflow**
helps you do these things.

There are convenience methods for:

- Parsing script arguments.
- Text decoding/normalisation.
- Storing data and settings.
- Caching data from, e.g., web services with a simple API for updating expired
- Securely storing (and syncing) passwords using OS X Keychain.
- Generating XML output for Alfred.
- Including external libraries (adding directories to ``sys.path``).
- Filtering results using an Alfred-like, fuzzy search algorithm.
- Generating log output for debugging.
- Running background processes to keep your workflow responsive.
- Capturing errors, so the workflow doesn't fail silently.

Quick Example

Here's how to show recent ` <>`_ posts in Alfred.

Create a new Workflow in Alfred's preferences. Add a **Script Filter** with
Language ``/usr/bin/python`` and paste the following into the **Script** field
(changing ``API_KEY``):

.. code-block:: python
:emphasize-lines: 4

import sys
from workflow import Workflow, ICON_WEB, web

API_KEY = 'your-pinboard-api-key'

def main(wf):
url = ''
params = dict(auth_token=API_KEY, count=20, format='json')
r = web.get(url, params)
for post in r.json()['posts']:
wf.add_item(post['description'], post['href'], arg=post['href'],
uid=post['hash'], valid=True, icon=ICON_WEB)

if __name__ == u"__main__":
wf = Workflow()

Add an **Open URL** action to your Workflow with ``{query}`` as the **URL**,
connect your **Script Filter** to it, and you can now hit **ENTER** on a
Pinboard item in Alfred to open it in your browser.


With pip

You can install **Alfred-Workflow** directly into your workflow with::

pip install --target=/path/to/my/workflow Alfred-Workflow

**Note**: If you intend to distribute your workflow to other users, you should
include **Alfred-Workflow** (and other Python libraries your workflow requires)
within your workflow as described. Do not ask users to install anything into
their system Python.

From source

Download the ```` file from the
`GitHub releases page <>`_
and either extract the ZIP to the root directory of your workflow (where
``info.plist`` is) or place the ZIP in the root directory and add
``sys.path.insert(0, '')`` to the top of your
Python scripts.

Alternatively, you can download
`the source code <>`_
from the `GitHub repository <>`_ and
copy the ``workflow`` subfolder to the root directory of your Workflow.

Your Workflow directory should look something like this (where
```` contains your Workflow code and ``info.plist`` is
the Workflow information file generated by Alfred)::

Your Workflow/

Or like this::

Your Workflow/


Detailed documentation, including a tutorial and auto-generated API docs, is
available at `the Alfred-Workflow website <>`_.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Alfred-Workflow, version 1.8.6
Filename, size File type Python version Upload date Hashes
Filename, size Alfred-Workflow-1.8.6.tar.gz (29.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page