Prepopulated Environment Variables
When running a workflow, Alfred prepopulates useful alfred_ variables with commonly required information. These are accessed like other variables, with one difference: in non-script Alfred objects the format is {const:myvariable} as opposed to {var:myvariable}.
Page Index
Workflow Variables
Information specific to the running workflow.
| Variable | Description |
|---|---|
alfred_workflow_bundleid |
Bundle identifier. |
alfred_workflow_name |
Name. |
alfred_workflow_description |
Description. |
alfred_workflow_version |
Version. |
alfred_workflow_uid |
Unique identifier. |
alfred_workflow_data |
Location for non-volatile data. |
alfred_workflow_cache |
Location for volatile data. |
Important
alfred_workflow_dataandalfred_workflow_cacheare based on the workflow's bundle identifier, thus are only set if the workflow has it configured. Their paths are predictable but they are not automatically created - do so in your code before placing files in them.
Example Values
alfred_workflow_bundleid = com.alfredapp.vitor.thumbnailnavigation
alfred_workflow_name = Thumbnail Navigation
alfred_workflow_description = Navigate the file system with previews
alfred_workflow_version = 2024.5
alfred_workflow_uid = ThumbnailNavigation.com.alfredapp.vitor.thumbnailnavigation
alfred_workflow_data = /Users/alfred/Library/Application Support/Alfred/Workflow Data/com.alfredapp.vitor.thumbnailnavigation
alfred_workflow_cache = /Users/alfred/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.alfredapp.vitor.thumbnailnavigation
Alfred Variables
Information on the running version of Alfred and its preferences.
| Variable | Description |
|---|---|
alfred_version |
Alfred version, without the build number. |
alfred_version_build |
Alfred build number. |
alfred_preferences |
Location of the Alfred Preferences bundle, taking sync state into consideration. |
alfred_preferences_localhash |
Mac-specific hash which identifies the local preferences folder stored within /preferences/local/ in the Alfred Preferences bundle. |
Example Values
alfred_version = 5.5.1
alfred_version_build = 2273
alfred_preferences = /Users/alfred/Library/Application Support/Alfred/Alfred.alfredpreferences
alfred_preferences_localhash = c797e62b26546f1d579b8ef658ebdc1fea21e140
Theming Variables
Information on the current theme.
| Variable | Description |
|---|---|
alfred_theme |
Identifier for current theme. |
alfred_theme_window_width |
Window width of the current theme. |
alfred_theme_background |
Background color of the current theme. |
alfred_theme_selection_background |
Background colour of the selected result. |
alfred_theme_subtext |
Result subtext mode set in the Alfred Preferences > Appearance > Options > Show result subtext. |
alfred_theme_subtext returns a code depending on the chosen option.
| Result Subtext Option | Result Subtext Code |
|---|---|
| Always | 0 |
| Only for Alternative Actions | 1 |
| Only for Selected Result | 2 |
| Never | 3 |
Example Values
alfred_theme = theme.bundled.moderndark
alfred_theme_window_width = 700
alfred_theme_background = rgba(0,0,0,0.40)
alfred_theme_selection_background = rgba(53,129,136,1.00)
alfred_theme_subtext = 0
Advanced Variables
| Variable | Description |
|---|---|
alfred_debug |
1 if the debug panel is open, otherwise it is not set. |
alfred_workflow_keyword |
Keyword used to start an action. Exclusive to the Script Filter Input. |