Keyboard shortcut (almost) never works for Automator service I have bash script that creates a screenshot in a given directory saved as an Automator service. I've then assigned ⇪⌘2 from System Preferences > Keyboard > Shortcuts > Services. The problem is that it doesn't work much at all. The only place I've found were it actually runs when using the macro is (how random) when click on the urlbar of Safari, and even then not without inconveniences, as it popups an error message saying "The “Take Screenshot” service could not be used because the “Take Screenshot” workflow did not provide valid data. - Try running the “Take Screenshot” workflow in Automator.", even though the process works fine and the screenshot is indeed captured and saved as intended. What's wrong?

fdate=`date`
screencapture "/Users/username/Unorganized/Studio/$fdate.png"
In summary you will need to use:


Automator to create a service that runs your bash script
System Preferences to assign a keyboard shortcut to the service


Below are the steps involved for each. 

1. Create a service using Automator


Launch Automator (usually found within your Applications folder)
Go to File > New
Select Service and click Choose
In the top right hand of the window that appears, ensure that "No input" is selected from the Service receives drop-down list
Ensure the In drop-down list is showing "Finder"
In the second column containing the long list, find "Run Shell Script" and double-click on it
This will add the Run Shell Script window on the right
Within the Run Shell Script section ensure you have selected the "/bin/bash" option for your Shell
Now add your code 
Save the service using a meaningful name (e.g. Take Reference Screenshot).


Now to the next step.

2. Creating your shortcut


Go to System Preferences > Keyboard > Shortcuts
Select Services from the sidebar
Find your service (it'll be in the list on the right-hand side)
Add a shortcut by double clicking on the service name
Now go to System Preferences > Security &amp; Privacy > Privacy
Select Accessibility in the sidebar
Click on the + sign (you may need to unlock the padlock if it's locked)
Add Automator.
Add Finder (to find this you will need to navigate to /System/Library/CoreServices/Finder.app).
Exit your System Preferences.


Let me know how you go.