Skip to main content

Full-featured helper library for writing Alfred 2/3/4 workflows

Project description

A helper library for writing Alfred 2, 3 and 4 workflows.

Supports macOS 10.7+ and Python 2.7 (Alfred 3 is 10.9+/2.7 only).

Alfred-Workflow is designed to take the grunt work out of writing a workflow.

It gives you the tools to create a fast and featureful Alfred workflow from an API, application or library in minutes.

http://www.deanishe.net/alfred-workflow/

Features

  • Catches and logs workflow errors for easier development and support

  • “Magic” arguments to help development/debugging

  • Auto-saves settings

  • Super-simple data caching

  • Fuzzy, Alfred-like search/filtering with diacritic folding

  • Keychain support for secure storage (and syncing) of passwords, API keys etc.

  • Simple generation of Alfred feedback (XML output)

  • Input/output decoding for handling non-ASCII text

  • Lightweight web API with modelled on requests

  • Pre-configured logging

  • Painlessly add directories to sys.path

  • Easily launch background tasks (daemons) to keep your workflow responsive

  • Check for new versions and update workflows hosted on GitHub.

  • Post notifications via Notification Center.

Alfred 3-only features

  • Set workflow variables from code

  • Advanced modifiers

  • Alfred 3-only updates (won’t break Alfred 2 installs)

  • Re-running Script Filters

Quick Example

Here’s how to show recent Pinboard.in 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):

import sys
from workflow import Workflow, ICON_WEB, web

API_KEY = 'your-pinboard-api-key'

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


if __name__ == u"__main__":
    wf = Workflow()
    sys.exit(wf.run(main))

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.

Installation

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’s directory as described below. Do not ask users to install anything into their system Python. Python installations cannot support multiple versions of the same library, so if you rely on globally-installed libraries, the chances are very good that your workflow will sooner or later break—or be broken by—some other software doing the same naughty thing.

With pip

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

# from within your workflow directory
pip install --target=. Alfred-Workflow

You can install any other library available on the Cheese Shop the same way. See the pip documentation for more information.

From source

Download the alfred-workflow-X.X.X.zip file from the GitHub releases page and extract the ZIP to the root directory of your workflow (where info.plist is).

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 yourscript.py contains your workflow code and info.plist is the workflow information file generated by Alfred):

Your Workflow/
    info.plist
    icon.png
    workflow/
        __init__.py
        background.py
        notify.py
        Notify.tgz
        update.py
        version
        web.py
        workflow.py
    yourscript.py
    etc.

Documentation

Detailed documentation, including a tutorial, is available at http://www.deanishe.net/alfred-workflow/.

Project details


Download files

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

Source Distribution

Alfred-Workflow-1.40.0.tar.gz (92.6 kB view details)

Uploaded Source

File details

Details for the file Alfred-Workflow-1.40.0.tar.gz.

File metadata

  • Download URL: Alfred-Workflow-1.40.0.tar.gz
  • Upload date:
  • Size: 92.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.16

File hashes

Hashes for Alfred-Workflow-1.40.0.tar.gz
Algorithm Hash digest
SHA256 c4c4f8037b0a0b192f4b79d6e1d8d1f7d1b7f0ebbf30905d1968f12caed40b16
MD5 216e85649976cb3114eaffcd6bdaa077
BLAKE2b-256 a765636e999af8a5f8a9642b19a0875799629cfbdf28cba441bb2f9107816b3f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page