caleb531 Posted June 7, 2023 Share Posted June 7, 2023 The Alfred documentation lists a number of Alfred-specific environment variables I can use in my workflow scripts. In my case, I'm using alfred_workflow_bundleid and alfred_workflow_data in my workflow. For example, here's some Python code from my workflow that uses these environment variables. Certainly, I can expect these variables to exist in Alfred 5, but I'm unsure of Alfred 4 support, so I've added hardcoded fallback values just in case. WORKFLOW_BUNDLE_ID = os.environ.get('alfred_workflow_bundleid', 'com.calebevans.youversionsuggest') HOME_DIR_PATH = os.path.expanduser('~') LOCAL_DATA_DIR_PATH = os.environ.get( 'alfred_workflow_data', os.path.join(HOME_DIR_PATH, 'Library', 'Application Support', 'Alfred', 'Workflow Data', WORKFLOW_BUNDLE_ID)) So how far back are these supported? Are they available in Alfred 4 or 3? https://alfredapp.com/help/workflows/script-environment-variables/ Thank you in advance! Caleb Sidenote: I originally posted this question on Twitter and was directed to ask it here on the forums. Link to comment
zeitlings Posted June 7, 2023 Share Posted June 7, 2023 v3 for sure, perhaps even as far back as v2.4 Link to comment
Andrew Posted June 7, 2023 Share Posted June 7, 2023 Most of the script environment variables available in Alfred 5 were also available in as far back as Alfred 2. Manually copying out from the Alfred 2 code so I may have missed one or two: alfred_version alfred_version_build alfred_theme alfred_theme_subtext alfred_theme_background alfred_preferences alfred_preferences_localhash alfred_workflow_uid alfred_workflow_bundleid alfred_workflow_cache alfred_workflow_data alfred_workflow_name I think you're safe to not need to code in fallbacks caleb531 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now