Jump to content

Search the Community

Showing results for tags 'howto'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
  • Alfred v2 Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting

Categories

  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Twitter


Website URL


Jabber


Location


Interests

Found 1 result

  1. Introduction Alfred workflows are simply zipped directories with an altered extension. Those are great news if you want to automate packaging your workflows for distribution, as you can simply (using ditto in this example, but zip would work just as well): ditto -ck "{{/path/to/your/workflow_directory}}" "{{/path/to/your/output_file}}.alfredworkflow" And that’s it. A zipped directory of your workflow with the custom .alfredworkflow extension. Names enclosed in double curly brackets are examples (they dependend on your situation and must be edited accordingly). Problem The trouble with that solution is that it packages your workflow as it is. Most of the time that won’t be a problem, but it becomes one when you have Workflow Environment Variables with “Don't Export” activated. Alfred knows not to save the value of those variables when exporting your workflow, but your zipping utility does not. Because of that, if you want to package your workflow yourself you need to set those variables (and only those) to empty values. Solution # You need only set these two variables, and the rest will work as is readonly workflow_dir="{{/path/to/your/workflow_directory}}" readonly output_file="{{/path/to/your/output_file}}.alfredworkflow" if /usr/libexec/PlistBuddy -c 'Print variablesdontexport' "${workflow_dir}/info.plist" &> /dev/null; then readonly workflow_dir_to_package="$(mktemp -d)" cp -R "${workflow_dir}/"* "${workflow_dir_to_package}" readonly tmp_info_plist="${workflow_dir_to_package}/info.plist" /usr/libexec/PlistBuddy -c 'print variablesdontexport' "${tmp_info_plist}" | grep ' ' | sed -E 's/ {4}//' | xargs -I {} /usr/libexec/PlistBuddy -c "set variables:'{}' ''" "${tmp_info_plist}" else readonly workflow_dir_to_package="${workflow_dir}" fi ditto -ck "${workflow_dir_to_package}" "${workflow_file}" So, what does this do? Check the info.plist in your workflow directory for the variablesdontexport property. If the property does not exist, package your workflow directory without any modifications. Our work is done. If the property exists, copy your entire workflow to a temporary directory (we’ll make changes to the info.plist and don’t want to do them on our current one). Check every variable in variablesdontexport and set them to empty values in the info.plist of the copied directory (we don’t want to outright delete the variables as the reference would be lost as well). Package the copied directory. Our work is done. Solution as a script #!/bin/bash readonly workflow_dir="${1}" readonly info_plist="${workflow_dir}/info.plist" if [[ "$#" -ne 1 ]] || [[ ! -f "${info_plist}" ]]; then echo 'You need to give this script a single argument: the path to a valid workflow directory.' exit 1 fi readonly workflow_name="$(/usr/libexec/PlistBuddy -c 'print name' "${info_plist}")" readonly workflow_file="${HOME}/Desktop/${workflow_name}.alfredworkflow" if /usr/libexec/PlistBuddy -c 'print variablesdontexport' "${info_plist}" &> /dev/null; then readonly workflow_dir_to_package="$(mktemp -d)" cp -R "${workflow_dir}/"* "${workflow_dir_to_package}" readonly tmp_info_plist="${workflow_dir_to_package}/info.plist" /usr/libexec/PlistBuddy -c 'Print variablesdontexport' "${tmp_info_plist}" | grep ' ' | sed -E 's/ {4}//' | xargs -I {} /usr/libexec/PlistBuddy -c "Set variables:'{}' ''" "${tmp_info_plist}" else readonly workflow_dir_to_package="${workflow_dir}" fi ditto -ck "${workflow_dir_to_package}" "${workflow_file}" echo "Exported worflow to ${workflow_file}." To use that script, give it a single argument: the path to the workflow you want to package. It’ll save it to the Desktop with the name automatically determined.
×
×
  • Create New...