Instantly Show or Hide Desktop Icons on your MAC
This is a simple Automator app written is shell script that toggles the visibility of desktop icons in macOS.
All you have to do is, download the app and extract the zip file.
After extracting the downloaded file, drag the "Show / Hide Desktop Icons" app to your Dock and you are done. Simple right?
Whenever you wish to hide the desktop icons, just click on the app icon in Dock and your desktop icons will disappear instantly. Don't worry you can access them normally from Finder.
To bring back desktop icons again, click the "Show / Hide Desktop Icons" app in Dock once again and BHOOM! They reappear as magic ;)
Under the hood
This app first checks the status of
com.apple.finder CreateDesktop default. If it returns
true, then the desktop icons are hidden with the command
defaults write com.apple.finder CreateDesktop false
and if it returns
false, desktop icons are set to visible by running the command
defaults write com.apple.finder CreateDesktop true
And every time Finder is restarted with the command