Automator Action to Toggle the Display of Desktop Icons in macOS

A

It’s no secret that Desktop icons can be hidden in macOS, but unlike many user-configurable options neither System Preferences nor the Finder‘s preferences provide a way to toggle their display. It’s true that the Desktop display of drive icons and some device icons can be controlled through the Finder, but in this context Desktop icons refer to all icons shown on the Desktop including those that represent folders, files or symbolic links.

The display of Desktop icons is controlled by the CreateDesktop key and its value in the com.apple.finder domain. By default this value is set to 1 – or true – which ensures icons are shown on the Desktop.

To hide Desktop icons we need to run the following two commands using Terminal or a similar terminal emulator:

Dummy Content
defaults write com.apple.finder CreateDesktop -bool false

 

 

Dummy Content
Killall Finder

 

 

These two commands can be combined into one, but it still needs to be executed from the command line:

Dummy Content
defaults write com.apple.finder CreateDesktop -bool false && killall Finder

 

 

Note: To show Desktop icons simply change false to true.

There are two applications I know of that allow you to hide or display Desktop icons. The ever-so-useful Onyx is donationware, but you need to authenticate when opening the application then drill-down through the menus to find the option. No big deal if you only occasionally want to hide or show Desktop icons.

While I may not want to change the visibility of Desktop icons regularly, when needed I want to do so with a couple of mouse clicks avoiding lengthy and easily forgotten Terminal commands. So I put together a simple Automator action that toggles the display of Desktop icons and is available from the Services menu of any application.

desktop-icons.workflow.zip7KB17th March 2020

After downloading, double-click the desktop-icons.workflow.zip 1 file and move the resulting Automator action Desktop Icons.workflow to the /Users/yourusername/Library/Services/ folder. Under macOS Mojave 10.14 2, the new action should automatically be included in the Services menu. To toggle the display of Desktop icons, select the App menu of any application, then choose Services > Desktop Icons.

Important: When Desktop icons are hidden, you cannot left-click the Desktop to give the Finder focus nor right [control]-click the Desktop to access its context menus. To use the Finder you need to navigate to it using the + keys. This is not a bug in the Automator action, but a direct result of setting the CreateDesktop key to false.

1 Safari will expand archive files automatically if its Open “safe” files after downloading preference is checked.

2 Earlier macOS releases my require a degree of finessing to get the action to show in the Services menu. If you’re having difficulty, first restart your Mac then open System Preferences > Keyboard > Shortcuts > Services, scroll to the General section at the end of the list and ensure the action is checked.

 

Change Log

 

0.9.1 Ensure desktop icons are hidden after initial run if CreateDesktop key doesn’t exist 2020-03-17
0.9.0 Initial Release 2018-12-22

About the author

A native Brit exiled in Japan, Steve spends too much of his time struggling with the Japanese language, dreaming of fish & chips and writing the occasional blog post he hopes others will find helpful.

1 response

1 Comment

  • Fantastic tip! Thanks for sharing, Steve. Was just looking into how to write this myself and you beat me to the punch… and saved me a few hours to boot!

Steve

Recent Comments

Recent Posts