Script Environment Variables

From Alfred v2.4, you'll find useful alfred_ variables in the script environment data, to help you get commonly required Alfred information from the user's settings.

Here is a list of the variables. Below, you'll also find an example of what you can expect this data to look like.

alfred_preferences

This is the location of the Alfred.alfredpreferences. If a user has synced their settings, this will allow you to find out where their settings are regardless of sync state.

alfred_preferences_localhash

From Alfred 2.4, non-synced preferences are moving out of the standard OS X preferences due to a Yosemite issue with prefs inheritance between Alfred Preferences.app and Alfred 2.app.

Any local (Mac-specific) preferences are now stored within Alfred.alfredpreferences under …/preferences/local/[alfred_preferences_localhash]/ instead and use Alfred's own preferences framework.

alfred_theme

Current theme used

alfred_theme_background

If you're creating icons on the fly, this allows you to find out the colour of the theme background.

alfred_theme_selection_background

The colour of the selected result.

alfred_theme_subtext

Find out what subtext mode the user has selected in the Appearance preferences.

Usability note: This is available so developers can tweak the result text based on the user's selected mode, but a workflow's result text should not be bloated unnecessarily based on this, as the main reason users generally hide the subtext is to make Alfred look cleaner.

alfred_version and alfred_version_build

Find out which version and build the user is currently running. This may be useful if your workflow depends on a particular Alfred version's features.

alfred_workflow_bundleid

The bundle ID of the current running workflow

alfred_workflow_cache and alfred_workflow_data

These are the recommended locations for volatile and non-volatile workflow data:

Cache: ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/[bundle id]
Data: ~/Library/Application Support/Alfred 2/Workflow Data/[bundle id]

Note that these two will only be populated if your workflow has a bundle id set.

alfred_workflow_name

Name of the currently running workflow

alfred_workflow_uid

Unique ID of the currently running workflow

alfred_debug

If the user currently has the debug panel open for this workflow. This variable is only set if the user is debugging, and is set to value 1.

Script Environment Variables Example

Here is an example of what you can expect from the data:

"alfred_preferences" = "/Users/Crayons/Dropbox/Alfred/Alfred.alfredpreferences";
"alfred_preferences_localhash" = adbd4f66bc3ae8493832af61a41ee609b20d8705;
"alfred_theme" = "alfred.theme.yosemite";
"alfred_theme_background" = "rgba(255,255,255,0.98)";
"alfred_theme_subtext" = 3;
"alfred_version" = "2.4";
"alfred_version_build" = 277;
"alfred_workflow_bundleid" = "com.alfredapp.david.googlesuggest";
"alfred_workflow_cache" = "/Users/Crayons/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.alfredapp.david.googlesuggest";
"alfred_workflow_data" = "/Users/Crayons/Library/Application Support/Alfred 2/Workflow Data/com.alfredapp.david.googlesuggest";
"alfred_workflow_name" = "Google Suggest";
"alfred_workflow_uid" = "user.workflow.B0AC54EC-601C-479A-9428-01F9FD732959";
"alfred_debug" = 1;
Latest Blog Post: Alfred 3 Is Here!
CacheFly Campaign Monitor

"Alfred" is a registered trademark of Running with Crayons Ltd. ©2016 Running with Crayons Ltd. All rights reserved.

Terms & Conditions, Privacy Policy, Cookies.