In today’s informational post I will show you how to hide icons on your Mac desktop. Not to worry, my PC Using friends, I will write up a quick how-to on the PC side at a later date!
This post has been updated! Please scroll to the bottom if you have difficulties with this action working on your computer!
Things you will need for this tutorial:
Any Mac – Bonus points if it is running 10.4 or newer!
Software you will need:
Automator, Included on all new macs and any mac running 10.4 or later.
Time to complete:
About 10 minutes (give or take) including testing for errors and such.
Start by opening the Automator.app on your mac, Spotlight will find it with a quick ⌘+Spacebar and typing ‘Auto’ (without quotes) otherwise look in Launch Pad or the Applications folder, whichever is easier for you.
Automator is a magnificent application. It can do anything you can imagine, and a few things you’ve not yet thought to imagine. As I said above, today our job/task is to hide everything visible on the desktop. This is an important and sometimes useful task as you might want to make a video-cast or something similar (screen sharing is a big one!) and not have your personal and private documents out there for the world to see.
If you have never run Automator Before, this next step may apply to you. If you have, choose the File menu and select “New…” (⌘+N) to follow along. If you are running Mavericks (these images are the Mavericks Version of Automator.app) We will start by choosing the ‘New Document’ button.
***IMPORTANT*** Make sure to click the On My Mac button at the top of this window FIRST! I have special instructions near the bottom of the post if you forgot to do that first.
Next the main Automator window will open and you will now have the option to choose what type of Automator Document we will be creating. For this tutorial, choose Service and either double-click the service icon, or click the icon and then the Choose Button.
Half way there!
The main Automator window is pretty straightforward, on the left we have the Library, which houses all of the applications that have direct automator actions available. the second column from the left is a listing of ALL of the actual services. and finally the workflow section on the right.
Below the services lists are a few bits of information. You will see an icon for a specific action and a description of its input and result data. You will also see a section for the version and vendor/copyright information.
To the right of the information section is a log and duration section (we will see this in action once we have a workflow to run!)
To start building our action, we will search for the ‘Run AppleScript’ action in the search field above the actions list.
Double-click or drag the Run AppleScript action into the workflow section and we will begin the coding part of this tutorial.
The next steps are important to follow as exactly as possible. Near the top of the workflow section it is important to select the ‘no input’ option of the Service receives selected menu, and the ‘any application’ in the second menu (as pictured).
To make things easier, I have included the code of our working script below:
set toggle to do shell script "defaults read com.apple.finder CreateDesktop"
if toggle = "0" then
do shell script "defaults write com.apple.finder CreateDesktop 1"
else if toggle = "1" then
do shell script "defaults write com.apple.finder CreateDesktop 0"
do shell script "killall Finder"
activate application "Finder"
Simply copy and paste this code into the action where the default script text lives (Replace everything you see with this code). You’re going to see purple text, that’s normal! If you click the little hammer icon to the right of the stop sign icon you will ‘compile’ the AppleScript. If any errors are displayed, double-check that you copied exactly (or if you typed it from the example, check all of the spelling and characters.
That’s actually all you really need to do to get this running! Now to test! there are two ways to test our script. First is the green button to the left of the stop sign and the other is in the top right side that says run. EITHER will work! But in the future when you are playing more in automator, you might find that the RUN button is not what you want if you are testing just a segment of your action (RUN is run everything, the Run AppleScripts own Run button only runs that segment of the workflow). Many workflows are different, so don’t be afraid to play around.
If you were successful in copying the action, and you hit the run button (either one) you should see any of your open Finder windows disappear for a moment and re-appear. You should also notice that your desktop icons have all vanished!
“Well, that’s great, now what do I do to get them back?” you might ask, well its simple, run the action again. Our code has a if statement that allows the computer to set the visibility on or off! so a single button shows and hides the icons. Its that easy!
Lets go about using this service!
Under the file menu choose ‘Save’ and the computer SHOULD give you the option to save your action and name it. If it does not, choose ‘Rename…’ and title the action something like “Toggle Desktop Icons”. Automator will change the name and append (Service) to the end of the name in the window title.
How to Hide : To use our newly created service in the wild you will need to perform two things. One: any application on your computer, go to the application menu (Finder, iTunes, TextEdit, Automator) and go to the Services item. Two: Choose the item that is the name of the service that you created in the last step. You should see the same visuals as before, either hiding or showing the desktop icons. You can also go to the Finder menu and select services, from there your service will be shown and you can toggle it there.
How To Show : If your desktop is already hidden you will notice one interesting side-effect of this system. You will not be able to right click on the desktop and have a menu appear. There is no solution for this issue, however do not fret. Clicking on the Services menu under the current application menu of the menu bar (think, Finder, Safari, or TextEdit, they all have a services menu!) will show you the same thing as before and you will be able to toggle the icon visibility all day!
Finally you could follow the steps in the advanced section to make a keyboard shortcut!
So that’s it! Everything clean and tidy! Sure there are free and paid programs out there that allow you to do the same thing, but sometimes its neat to learn about the tools you have at your disposal.
Want to learn more? Have a question what this service is actually doing? Send me an email and we can talk about it and more! email@example.com
iCloud Got You Down?
If you went quickly and didn’t choose the On My Mac button in the early steps. Don’t worry, there is a way to make this all work (as you wont see your service in the services section of the contextual menu (or the services section of the Finder Menu for that matter))
First, If you have any Automator windows open, close them individually.
Next, quit Automator.
Re Open Automator. In my tests, it was easiest to make a NEW action before the next step.
Go to File and choose Open Recent and then choose the workflow you just created (the one locked up in iCloud) You should see a dialogue that asks if you want to install a service. If you dont see it, try right/⌘ (not control) clicking on the Title of the window. If you see a path that looks something like this: You’re good!
Okay, so you have a service, and it’s installed to the point of usefulness, now what? Well, why not make a keyboard short-cut. One important thing about our existing service is that we already set it up to work anywhere on the computer, no matter what is the current running application. You can go anywhere and go to the Application’s menu, then choose the services menu and finally your command. But why not make it a keyboard shortcut too?
This is so easy, you might start making keyboard shortcuts for nearly anything!
Start out by going to the Apple Menu, or Spotlight and find System Preferences.
Once System Preferences is open, choose Keyboard.
In the screenshot provided, I’ve already selected Shortcuts, and then Services on the left side column. If you scroll in this list you can find the General section. Here you should see the name of your service, just like you would expect it spelled out. If you click on the service on the service you will see a button show up that says ‘add shortcut’. From here its easy, press and hold the sequence of keys you wish to use to make your shortcut. I like the combination ⇧+⌘+⌥+T, its just enough keys to be sure it wont conflict with any other shortcut, and It will also keep me from pressing it by accident.
There are no additional steps. Once you have pressed the keys the system automatically saves it, AND it even makes the shortcut immediately available for anything to use. since you made a system wide service, try the keystroke now! pretty nifty, eh?!
It has come to my attention that in order for this script to work properly, you must first allow your computer to understand the CreateDesktop command. As strange as it sounds, you have to force either the 0 or 1 in the code above to be written. In the simplest method possible, open a new automator action (you won’t be saving this one, don’t worry) set it up like the action we create above, but with one difference, use this code and simply run the action. Again, no need to save it, just run it and close the window without saving.
do shell script "defaults write com.apple.finder CreateDesktop -bool true"