Set your screenshot defaults with Keyboard Maestro

In my daily work I'm taking quite a few screenshots. Depending on the use case I need them in different formats and also to be stored in particular folders, for example:

  • JPG on the desktop for an email
  • PDF for annotations into the DEVONthink inbox
  • PNG into the image folder of the website

OS X offers to set the image format and destination folder for the captures by using the defaults command in the terminal:

defaults write type format
defaults write location path

The format can be png, jpg, tiff or pdf, while path must be the path to a folder in Unix style. After using the commands you have to restart the background process to load the new settings:

killall SystemUIServer

To be able to change these settings on the fly I wrapped them in a Keyboard Maestro macro:

Macro: Defaults Screenshot

Step 1: The action "Prompt for User Input" lets you choose the format and the path. Both are using predefined menus. Each of their entries are separated with a pipe character |. For the path entries I'm also using a very handy feature of Keyboard Maestro:

If a component of a popup menu item starts with a prefix followed by two underscores, then the prefix will be used as the variable value, while the latter part will be displayed in the menu.

Instead of the long and harder to read path names, the result is a clean dropdown list:

Defaults Screenshot - User Input

Step 2: This is the core action of the macro. The two variables of step 1 are used to set the defaults, the SystemUIServer gets restarted and the result is saved to a variable.

Step 3: Depending on the result of step 2 either a success message (variable is empty) or an error description (content of the variable) is displayed. The latter should actually only appear if something is wrong with the path.

You can download the macro at my Keyboard Maestro Repository on Github. Don't forget to adjust the paths to your own requirements and to assign a trigger.