blach.io

Script to hide desktop icons and Dock when creating OS X screenshots

When creating screenshots for the latest version of Textastic for Mac in OS X Yosemite, I needed a way to quickly hide the Dock and all desktop icons without using a separate demo account on my Mac.

This is the resulting shell script:

toggle_presentation_desktop.command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

if [[ $(defaults read com.apple.finder CreateDesktop) = 1 ]]
then
  echo "enabling presentation mode"
  defaults write com.apple.finder CreateDesktop -bool false
 osascript -e "tell application \"System Events\" to set the autohide of the dock preferences to true"
  killall Finder
else
  echo "disabling presentation mode"
  defaults write com.apple.finder CreateDesktop -bool true
 osascript -e "tell application \"System Events\" to set the autohide of the dock preferences to false"
  killall Finder
fi
make script executable
1
chmod +x toggle_presentation_desktop.command

Setting the “CreateDesktop” default to false hides the desktop icons, but still displays the wallpaper. The script uses AppleScript to hide the Dock.

Now I can just use Spotlight to execute the toggle_presentation_desktop.command shell script and it will toggle the Dock and desktop icons.

I also used Bartender to hide all menu bar icons except Spotlight and Notification Center.

This is one of the resulting screenshots: