Hide And Show Desktop Icons On OS X With An Automator Service

Hide And Show Desktop Icons On OS X With An Automator Service


A cluttered desktop is not only distracting, it can slow down your Mac. If you want to temporarily hide your Mac’s desktop icons, you can do so with a simple AppleScript and Automator.

We featured this tip way back in 2010, but the command to perform this task has changed, so we’ve updated the post with the correct code.

Essentially, if you want to do this from the terminal, you can just run:

defaults write com.apple.finder CreateDesktop false; killall Finder

And replace “false” with “true” when you want to re-show them.

If it’s something you’re going to run regularly, it can be handy to put it into an AppleScript or Automator service so you can easily toggle it on and off with a few clicks. Here’s an AppleScript that does just that:

try
set toggle to do shell script "defaults read com.apple.finder CreateDesktop"
if toggle = "true" then
do shell script "defaults write com.apple.finder CreateDesktop false"
else if toggle = "false" then
do shell script "defaults write com.apple.finder CreateDesktop true"
end if
end try

do shell script "killall Finder"
delay 0.5
activate application "Finder"

The most versatile way to use this AppleScript would be to throw it into Automator and create a simple one-click switch. To do so, just open up Automator and choose Service as a template. At the top of the workflow, select Finder for the right drop-down box and “no input” for the left drop-down (so it reads “Service receives no input from Finder”). Then, find the “Run AppleScript” action in the left sidebar and drag it into the workflow.

Next, paste the above code into the Run AppleScript box (replacing everything that was there). Save the Service as “Toggle Clean Desktop”, or whatever other title you like, and it will be accessible from the Finder > Services menu in the menu bar. If you like, you can even assign a keyboard shortcut under System Preferences > Keyboard > Keyboard Shortcuts. Check out the video above for a demonstration.

Note: You’ll need to run the terminal command on its own at least once before the AppleScript will work properly!

Of course, you can also download an app like Camouflage, but it’s $6.49 for something you can very simply do yourself.


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


Leave a Reply