Alfred 2 Development Libraries

Below are a few libraries that are available to expedite workflow development. The text below is taken wholesale from the Alfred support forums. Currently, the forums are the best source to read up and have your questions answered.

Find them here, for now.

Python

Deanish recently (07 Mar 2014) released a 70kb Python library that has quite a few features for its size. Read about it on the Alfred Forums, check out the library's documentation page, or find it on Github.

Alp (developed by phyllisstein)

Note: alp is abandonware at this point. But it still works, and the author is open to pull requests and encourages anyone to fork the library. Alp is a Python module for developing Alfred workflows that bridges the gaps between Python and OS X and Python and Alfred, making the process of creating a workflow quick and easy. As it's essentially a collection of shortcuts for common and repetitive tasks, developers will find that working with alp results in less and more efficient code and a generally more sane workflow development experience. A painstaking guide to its various features, bells, and whistles is available in the README at the Github repository.

Features:

Simplified generation of feedback XML. Shortcuts for bundle ID, storage paths, settings, and arbitrary plist and JSON files. OS X interaction features, including the sending of additional notifications, interaction with the Keychain, and interaction with Spotlight. Internet interaction features, including bundled modules for making and caching HTTP requests, parsing markup data, and sending e-mail. The ability to remove unneeded modules for a svelte workflow bundle.

 

Alfred-Python (developed by JinnLynn)

alfred-python is a full-featured python module that helps building Alfed workflow quick and easy.

Features:

Simple feedback XML generation Provides functions for storing or retrieving cache data Workflow configuration management Includes an easy way to download remote file Easily get bundle id, query arguments, etc.

More code example can be found on my own workflows.

PHP

Workflows (developed by David Ferguson)

Workflows is a PHP library for building Alfred 2 workflows using PHP. Installation is quick and easy. Just drop in the Workflows.php class file, import it into your code, and initialize it. Full documentation, with usage examples can be found on David's blog.

Features:

Simple XML generation Read/writing files as plain text, json, etc. Read/write plist values Find local files Provide access to commonly used paths (home, cache, current, data storage, etc) Easy HTTP/cURL requests

AppleScript

qWorkflow (developed by ursanrazvan)

qWorkflow is an AppleScript library for creating workflows with Alfred 2. This library provides an object-oriented approach for working with plist settings files, reading and writing data to files, generating Alfred feedback results, requesting remote data, parsing JSON data, and more.

Features:

object-oriented approach to write less & more readable code heavily documented with code samples internal workflow introspection (finding the bundle ID, cache & storage paths) generate Alfred-compatible XML feedback with ease saving & retrieving workflow-related settings (with support for default settings file) remote data requests, as well as JSON support sending notifications through the Notification Center various internal utilities that improve AppleScript (string and date manipulation, file system utilities)

More info & example workflows created with this support library can be found on the project's github repo

Go

goAlfred (Developed by raguay.customct

This go library is used to create workflows for Alfred 2 easier in the go language from Google (http://golang.org/). It will automatically create your cache and data directories. It also creates the xml listing for the feedback system. Examples included.

Installation and Usage

You install the library with:go get github.com/raguay/goAlfred # (You might have to use sudo). Any program that you want to use the library, just place this line in it: import "github.com/raguay/goAlfred"

Functions

The accessible function calls are:

  • goAlfred.BundleId() - This will get your Bundle Id for your workflow. 
  • goAlfred.Cache() - This function returns the location of your cache directory.
  • goAlfred.Home() - This function returns the location of your home directory.
  • goAlfred.Data() - This function returns the location of your workflow's data directory.
  • goAlfred.Path() - This function returns the location of your workflow's directory.
  • goAlfred.Error() - Returns the last error received.
  • AddResult( uid string, arg string, title string, sub string, icon string, valid string, auto string, rtype string) - This function allows you to build up the xml string for returning to Alfred.
  • AddResultSimilar(instring string, uid string, arg string, title string, sub string, icon string, valid string, auto string, rtype string) - This function allows you to build up the xml string for returning to Alfred only if the title is similar to the instring given.
  • goAlfred.SetDefaultString(title string) - This function sets a different default message if no results have been added.
  • goAlfred.GetXML() - This function returns the XML string that needs to be given to Alfred.

Swift

Alfred Swift Library is a copy of the goAlfred library for Swift. Done by Richard Guay.

Bash

BashWorkflowHandler (developed by _mk_)

Features:

  • create feedback xml
  • save/read preferences volatile and non-volatile
  • get workflow's cache dir
  • get workflow's data dir
  • get workflow's bundle id

Usage examples can be found in the README at the GitHub repo.

Ruby

Alfred2-Ruby-Template (developed by zhauwu)

A template for Ruby-based Alfred 2 workflow development.

Features:

  • Use standard bundler to easily package, manage, and update ruby gems in the workflow.
  • Friendly exception and debug output to the Mac OS X Console
  • Automate rescue feedback items to Alfred when something goes wrong.
  • Automate saving and loading cached feedback

 

Alfredo (developed by Dennis Paagman)

Alfredo is simple ruby gem that makes it easy to create workflows and items to it. You can get started with only 4 lines of code.

Features:

  • Generates valid Workflow XML
  • Add items with one line of code
  • Supports all Alfred 2 workflow features