A helper library in Python for authors of workflows for Alfred 2.
Supports OS X 10.6+ (Python 2.6 and 2.7).
- 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 of passwords, API keys etc.
- Simple generation of Alfred feedback (XML output)
- Input/output decoding for handling non-ASCII text
- Lightweight web API with Requests-like interface
- 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.
- Installation
- Usage
- Documentation
- Licensing, thanks
- Contributing
- Tests
- Workflows using 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'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.
You can install Alfred-Workflow directly into your workflow with:
pip install --target=/path/to/my/workflow 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
from the releases page. - Either extract the ZIP archive and place the
workflow
directory in the root folder of your workflow (whereinfo.plist
is) or - Place the ZIP archive in the root folder of your workflow and add
sys.path.insert(0, 'alfred-workflow-X.X.X.zip')
at the top of your Python script(s).
Your workflow should look something like this:
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.
Or this:
Your Workflow/
info.plist
icon.png
workflow-1.X.X.zip
yourscript.py
etc.
Note: the background.py
module will not work from within a zip archive.
Alternatively, you can clone/download the Alfred-Workflow repository and copy the workflow
subdirectory to your workflow's root directory.
A few examples of how to use Alfred-Workflow.
Set up your workflow scripts as follows (if you wish to use the built-in error handling or sys.path
modification):
#!/usr/bin/python
# encoding: utf-8
import sys
from workflow import Workflow
def main(wf):
# The Workflow instance will be passed to the function
# you call from `Workflow.run`
# Your imports here if you want to catch import errors
# or if the modules/packages are in a directory added via `Workflow(libraries=...)`
import somemodule
import anothermodule
# Get args from Workflow, already in normalised Unicode
args = wf.args
# Do stuff here ...
# Add an item to Alfred feedback
wf.add_item(u'Item title', u'Item subtitle')
# Send output to Alfred
wf.send_feedback()
if __name__ == '__main__':
wf = Workflow()
sys.exit(wf.run(main))
Cache data for 30 seconds:
def get_web_data():
return web.get('http://www.example.com').json()
def main(wf):
# Save data from `get_web_data` for 30 seconds under
# the key ``example``
data = wf.cached_data('example', get_web_data, max_age=30)
for datum in data:
wf.add_item(datum['title'], datum['author'])
wf.send_feedback()
Grab data from a JSON web API:
data = web.get('http://www.example.com/api/1/stuff').json()
Post a form:
r = web.post('http://www.example.com/', data={'artist': 'Tom Jones', 'song': "It's not unusual"})
Upload a file:
files = {'fieldname' : {'filename': "It's not unusual.mp3",
'content': open("It's not unusual.mp3", 'rb').read()}
}
r = web.post('http://www.example.com/upload/', files=files)
WARNING: As this module is based on Python 2's standard HTTP libraries, it does not validate SSL certificates when making HTTPS connections on older versions of OS X/Python. If your workflow uses sensitive passwords/API keys, you should strongly consider using the requests library upon which the web.py
API is based.
Save password:
wf = Workflow()
wf.save_password('name of account', 'password1lolz')
Retrieve password:
wf = Workflow()
wf.get_password('name of account')
The full documentation, including API docs and a tutorial, can be found at deanishe.net.
There is a mirror at Read the Docs.
The code and the documentation are released under the MIT and Creative Commons Attribution-NonCommercial licences respectively. See LICENCE.txt for details.
The documentation was generated using Sphinx and a modified version of the Alabaster theme by bitprophet.
Many of the cooler ideas in Alfred-Workflow were inspired by Alfred2-Ruby-Template by Zhaocai.
The Keychain parser was based on Python-Keyring by Jason R. Coombs.
If you want to add a workflow to the list of workflows using Alfred-Workflow, don't add it to this README! The list is machine-generated from Packal.org and the library_workflows.tsv
file. If your workflow is available on Packal, it will be added automatically. If not, please add it to library_workflows.tsv
, instead of README.md
, and submit a corresponding pull request.
The list is not auto-updated, so if you've released a workflow and are keen to see it in this list, please open an issue asking me to update the list.
Bug reports, feature suggestions and pull requests are very welcome. Head over to the issues if you have a feature request or a bug report.
If you want to make a pull request, do that here, but please bear the following in mind:
- Please open pull requests against the
develop
branch. I try to keepmaster
in sync with the latest release (at least regarding any files included in releases).master
anddevelop
are usually in sync, but if I'm working on new features, they'll be indevelop
and won't be pushed tomaster
until they're ready for release. - Alfred-Workflow has very close to 100% test coverage. "Proof-of-concept" pull requests without tests are more than welcome. However, please be prepared to add the appropriate tests if you want your pull request to be ultimately accepted.
- Complete coverage is only a proxy for decent tests. Tests should also cover a decent variety of valid/invalid input. For example, if the code could potentially be handed non-ASCII input, it should be tested with non-ASCII input.
- Code should be PEP8-compliant as far as is reasonable. Any decent code editor has a PEP8 plugin that will warn you of potential transgressions.
- Please choose your function, method and argument names carefully, with an eye to the existing names. Obviousness is more important than brevity.
- Document your code using the Sphinx ReST format. Even if your function/method isn't user-facing, some other developer will be looking at it. Even if it's only a one-liner, the developer may be looking at the docs in a browser, not at the source code. If you don't feel comfortable writing English, I'd be happy to write the docs for you, but please ensure the code is easily understandable (i.e. comment the code if it's not totally obvious).
- Performance counts. By default, Alfred will try to run a workflow anew on every keypress. As a rule, 0.3 seconds execution time is decent, 0.2 seconds or less is smooth. Alfred-Workflow should do its utmost to consume as little of that time as possible.
The main entry point for unit testing is the run-tests.sh
script in the root directory. This will fail if code coverage is < 100%. Travis-CI also uses this script. Add # pragma: no cover
with care.
Alfred-Workflow includes a full suite of unit tests. Please use the run-tests.sh
script in the root directory of the repo to run the unit tests: it creates the necessary test environment to run the unit tests. test_workflow.py
will fail if not run via run-scripts.sh
, but the test suites for the other modules may also be run directly.
Moreover, run-tests.sh
checks the coverage of the unit tests and will fail if it is below 100%.
These are some of the Alfred workflows that use this library.
- Alfred Backblaze (GitHub repo) by XedMada (on GitHub). Pause and Start Backblaze online backups.
- Alfred Dependency Bundler Demo (Python) (GitHub repo) by deanishe (on GitHub). Demonstration on how to use the Alfred Bundler in Python.
- Alfred Keyword Help (GitHub repo) by pochemuto (on GitHub). Show and filter available keywords.
- Alfred Soundboard by Steffen. A soundboard for alfred at your fingertips.
- Alfred-Drive-Workflow (GitHub repo) by azai91 (on GitHub). Browse, search and open Google Drive files from within Alfred.
- Alfred-Flixsearch (GitHub repo) by deanishe (on GitHub). What's available on Netflix and in which countries.
- Alfred-Venmo-Workflow (GitHub repo) by azai91 (on GitHub). Pay and charge friends easily in venmo.
- alfredwl (GitHub repo) by nicke5012 (on GitHub). Wunderlist integration for Alfred2. Allows you to add tasks, show your lists, and show incomplete tasks through Alfred.
- AppScripts (GitHub repo) by deanishe (on GitHub). List, search and run/open AppleScripts for the active application.
- Base Converter (GitHub repo) by ahalbert (on GitHub). Convert arbitrary bases(up to base 32) in Alfred 2 and copy them to the clipboard.
- BeautifulRatio (GitHub repo) by yusuga (on GitHub). This workflow calculates the Golden ratio and Silver ratio.
- Better IMDB search by frankspin. Search IMDB for movies and see results inside of Alfred.
- BibQuery (GitHub repo) by hackademic (on GitHub). Search BibDesk from the comfort of your keyboard.
- Blur by Tyler Eich. Set Alfred's background blur radius.
- Calendar (GitHub repo) by owenwater (on GitHub). Displays a monthly calendar with Alfred Workflow.
- CDN (GitHub repo) by azai91 (on GitHub). Find CDNs quick with Alfred.
- Code Case by dfay. Case Converter for Code.
- Codebox (GitHub repo) by danielecook (on GitHub). Search codebox snippets.
- Continuity Support by dmarshall. Enables calling and messaging via contacts or number input.
- Convert (GitHub repo) by deanishe (on GitHub). Convert between different units. No Internet connection required.
- Date Calculator (GitHub repo) by MuppetGate (on GitHub). A basic date calculator.
- Digital Ocean status (GitHub repo) by frankspin (on GitHub). Control your Digital Ocean droplets.
- Display Brightness (GitHub repo) by fniephaus (on GitHub). Adjust your display's brightness with Alfred.
- Dropbox Client for Alfred (GitHub repo) by fniephaus (on GitHub). Access multiple Dropbox accounts with Alfred.
- Duden Search (GitHub repo) by deanishe (on GitHub). Search duden.de German dictionary (with auto-suggest).
- Fabric for Alfred by fniephaus. Quickly execute Fabric tasks.
- Fakeum (GitHub repo) by deanishe (on GitHub). Generate fake test data in Alfred.
- Forvo (GitHub repo) by owenwater (on GitHub). A pronunciation workflow based on Forvo.com.
- Fuzzy Folders (GitHub repo) by deanishe (on GitHub). Fuzzy search across folder subtrees.
- Genymotion (GitHub repo) by yakiyama (on GitHub). Start emulator instantly.
- Gist (GitHub repo) by danielecook (on GitHub). An alfred workflow for accessing github gists as snippets. Supports tags, stars, and private gists.
- Git Repos (GitHub repo) by deanishe (on GitHub). Browse, search and open Git repositories from within Alfred.
- gitignore (GitHub repo) by jdno (on GitHub). Create .gitignore files using Alfred.
- Glosbe Translation (GitHub repo) by deanishe (on GitHub). Translate text using Glosbe.com.
- Gmail Client for Alfred (GitHub repo) by fniephaus (on GitHub). Manage your Gmail inbox with Alfred.
- HackerNews for Alfred (GitHub repo) by fniephaus (on GitHub). Read Hacker News with Alfred.
- Hayaku (GitHub repo) by kizu (on GitHub). Expands fuzzy CSS abbreviations.
- HGNC Search (GitHub repo) by danielecook (on GitHub). Search for human genes.
- Homebrew and Cask for Alfred (GitHub repo) by fniephaus (on GitHub). Easily control Homebrew and Cask with Alfred.
- IME (GitHub repo) by owenwater (on GitHub). A Input method workflow based on Google Input Tools.
- iOS Simulator (GitHub repo) by jfro (on GitHub). Workflow for finding simulator app data folders, erasing apps and more.
- IPython Notebooks (GitHub repo) by nkeim (on GitHub). Search notebook titles on your IPython notebook server.
- Jenkins (GitHub repo) by Amwam (on GitHub). Show and search through jobs on Jenkins.
- Jira Task Manager (GitHub repo) by miguelpuyol (on GitHub). A Jira Task Manager for Alfred.
- Jisho v1.0 (GitHub repo) by kylesezhi (on GitHub). Translate English and Japanese words with Jisho.org.
- Julian Date calculator (GitHub repo) by Tam-Lin (on GitHub). Converts dates to/from Julian dates, as well as some date math.
- KA Torrents by hackademic. Search and download torrents from kickass.so.
- Laser SSH by paperElectron. Choose SSH connection from filterable list.
- LastPass Vault Manager (GitHub repo) by bachya (on GitHub). A workflow to interact with a LastPass vault.
- LibGen (GitHub repo) by hackademic (on GitHub). Search and Download pdfs and ebooks from Library Genesis.
- MailTo (GitHub repo) by deanishe (on GitHub). Send mail to contacts and groups from your Address Book.
- moment (GitHub repo) by perfectworks (on GitHub). Advanced time utility.
- Movie and TV Show Search (GitHub repo) by tone (on GitHub). Search for movies and tv shows to find ratings from a few sites.
- Movie Ratings (GitHub repo) by mattsson (on GitHub). Search for a movie and see its IMDb, Rotten Tomatoes and Metacritic ratings.
- Myinstants (GitHub repo) by flipxfx (on GitHub). A workflow to search Myinstants.com.
- Network Location (GitHub repo) by deanishe (on GitHub). List, filter and activate network locations from within Alfred.
- Order of Magnituce by tdhopper. Convert a number to natural language (rounded to any number of places).
- Packal Workflow Search (GitHub repo) by deanishe (on GitHub). Search Packal.org from the comfort of Alfred.
- Pandoctor (GitHub repo) by hackademic (on GitHub). An Alfred GUI for Pandoc.
- Parsers (GitHub repo) by hackademic (on GitHub). Greek and Latin parsers.
- pass (GitHub repo) by mwest (on GitHub). Provide a minimal wrapper over the pass password manager (passwordstore.org).
- Percent Change (GitHub repo) by bkmontgomery (on GitHub). Easily do percentage calculations.
- PERT Calculator by agileadam. Generates accurate time estimates based on optimistic, realistic, and pessimistic expectations.
- PHPStorm project opener (GitHub repo) by hansdubois (on GitHub). PHPStorm project opener.
- Pocket for Alfred (GitHub repo) by fniephaus (on GitHub). Manage your Pocket list with Alfred.
- Product Hunt (GitHub repo) by loris (on GitHub). List Product Hunt today's hunts.
- ProductHunt (GitHub repo) by chiefy (on GitHub). Read ProductHunt in Alfred.
- PWS History (GitHub repo) by hrbrmstr (on GitHub). Retrieve personal weather station history from Weather Underground.
- Quick Stocks by paperElectron. Add some stock symbols for Alfred to check for you.
- Ramda Docs (GitHub repo) by raine (on GitHub). Search Ramda documentation.
- Rates (GitHub repo) by Kennedy Oliveira (on GitHub). Simple exchange rates for alfred.
- Readability for Alfred (GitHub repo) by fniephaus (on GitHub). Manage your Readability list with Alfred.
- Reddit (GitHub repo) by deanishe (on GitHub). Browse Reddit from Alfred.
- Relative Dates (GitHub repo) by deanishe (on GitHub). Generate relative dates based on a simple input format.
- Resolve URL (GitHub repo) by deanishe (on GitHub). Follows any HTTP redirects and returns the canonical URL. Also displays information about the primary host (hostname, IP address(es), aliases).
- Rotten Search (GitHub repo) by yakiyama (on GitHub). Search movie from RottenTomatoes.com.
- Search Omnifocus (GitHub repo) by rhyd (on GitHub). This is a workflow that performs free text searches on OmniFocus data.
- Searchio! (GitHub repo) by deanishe (on GitHub). Auto-suggest search results from multiple search engines and languages.
- Secure Password Generator (GitHub repo) by deanishe (on GitHub). Generate secure random passwords from Alfred. Uses /dev/urandom as source of entropy.
- SEND by hackademic. Send documents to the cloud.
- Seq-utilies (GitHub repo) by danielecook (on GitHub). Fetch complement, reverse complement, RNA, and protein sequences. Generate random DNA. Blast a sequence.
- Simple Timer by Paul Eunjae Lee. A very simple timer.
- Skimmer (GitHub repo) by hackademic (on GitHub). Actions for PDF viewer Skim.
- slackfred (GitHub repo) by frankspin (on GitHub). Interact with the chat service Slack via Alfred (multi-org supported).
- Snippets (GitHub repo) by hackademic (on GitHub). Simple, document-specific text snippets.
- Splatoon (GitHub repo) by flipxfx (on GitHub). A workflow with Splatoon helpers (maps, wiki).
- Spritzr (GitHub repo) by hackademic (on GitHub). An Alfred Speed-Reader.
- Stack Overflow (GitHub repo) by Que3216 (on GitHub). Get answers to simple questions like "python function syntax", without having to open your web browser.
- StackOverflow Search (GitHub repo) by deanishe (on GitHub). Search StackOverflow.com from Alfred.
- Star Ratings (GitHub repo) by deanishe (on GitHub). View and set ratings for your files and folders.
- Steam by tresni. Activate your Steam codes & launch steam games with a quick keystroke or keyword.
- Sublime Text Projects (GitHub repo) by deanishe (on GitHub). View, filter and open your Sublime Text (2 and 3) project files.
- Torrent (GitHub repo) by bfw (on GitHub). Search for torrents, choose among the results in Alfred and start the download in uTorrent.
- Travis CI for Alfred by fniephaus. Quickly check build statuses on travis-ci.org.
- UberTime (GitHub repo) by frankspin (on GitHub). Check estimated pick up time for Uber based on inputted address.
- URL craft by takanabe. A workflow that transforms a url into new one that allows some formats such as "Github Flavored Markdown link" or "shorten url" and so on.
- VagrantUP (GitHub repo) by m1keil (on GitHub). List and control Vagrant environments with Alfred2.
- Viscosity VPN Manager (GitHub repo) by deanishe (on GitHub). Manage Viscosity VPN connections.
- VM Control (GitHub repo) by fniephaus (on GitHub). Control your Parallels and Virtual Box virtual machines.
- VPN Switch (GitHub repo) by flyeek (on GitHub). Switch VPN on/off.
- Wikify (GitHub repo) by hackademic (on GitHub). Your little Evernote Wiki-Helper.
- Workon Virtualenv (GitHub repo) by johnnycakes79 (on GitHub). Workflow to list and start python virtualenvs (assumes you and have virtualenv and virtualenvwrapper installed).
- Wowhead (GitHub repo) by owenwater (on GitHub). An Alfred workflow that helps you search World of Warcraft® database provided by wowhead.com.
- Wunderlist Workflow for Alfred (GitHub repo) by ipaterson (on GitHub). Unbelievably fast entry for tasks with due dates, reminders, and recurrence in Wunderlist.
- Wunderlist3.alfredworkflow (GitHub repo) by gnostic (on GitHub). A Wunderlist 3 API cloud-based alfred workflow.
- Youdao Dict (GitHub repo) by WhyLiam (on GitHub). 使用有道翻译你想知道的单词和语句.
- Youtrack - create issues (GitHub repo) by altryne (on GitHub). Creates issues in Your Youtrack installation.
- ZotQuery (GitHub repo) by hackademic (on GitHub). Search Zotero. From the Comfort of Your Keyboard.