This free app may be useful to you. It does not exactly do what you ask, but it comes close, and there may be ways to further automate it to get even closer.
http://www.shirt-ediss.me/clarity/
When this is installed as directed, a couple of simple terminal commands, e.g.:
$ sw 0
$ sw 1
let you empty the desktop of icons (except for mounted drives, if you have your desktop configured to show them) and then switch back to your standard desktop.
In my initial testing (I just installed it tonight) it takes about 2 seconds to clear the desktop and about 4 seconds to restore it.
Clarity has the added advantage of letting you save various desktop configurations to switch back and forth among, identified by either number or a text name. In the above commands, you could also type
$ sw home
which may be more mnemonic if you have saved dozens of desktop configurations.
If you want to have the Clarity commands automatically invoked to change the icons when you move between desktop workspaces, as in the OP, I believe you can achieve that using the free Mac program CurrentKey Stats (https://currentkey.com/). The latest version (12/2020) adds the feature of "Bi-directional AppleScript support". As described on the CurrentKey web page:
CurrentKey can also notify your own custom AppleScript every time you switch between Rooms. This enables you to trigger Room-specific functionality outside of the app.
While I have not tested that feature of CurrentKey, I've corresponeded with the developer and I use it for switching between workspace desktops constantly.
It seems like it would be a straighforward task to have CurrentKey trigger an AppleScript function that runs sw 0
when you enter a specific workspace and then run sw 1
when you leave it. If I were more facile with AppleScript, I would knock one up right now to try it and complete this answer.
Another technique for clearing and restoring the desktop icons is described at Hide files/icons on the desktop but not in finder. While Clarity (above) empties the Desktop
folder and then restores it from saved snapshots, the technique on that thread addresses the need to have the contents of the Desktop
folder stay intact. It turns off or on a Finder default setting and then kills the Finder app so that it restarts.
When I tried it, the icons went away instantly, but so did my Finder windows, which then took about 12 seconds to be automatically restarted. When restoring the desktop, the Finder windows were again restored in about 12 seconds with the desktop icons following a few seconds later. Personally, I would find it disturbing to have that automatically happen whenever I changed desktop workspaces. If you absolutely need to access the contents of your Desktop directory while the icons are hidden, that delay may be worth it to you.
I hope this helps.
In the terminal, do this:
defaults write com.apple.finder CreateDesktop -bool false && killall Finder
After this, there'll be nothing on your Desktop (but still in ~/Desktop
, i.e. your Desktop Folder). It'll look like this:
Beautiful, isn't it? If you want to change it back:
defaults write com.apple.finder CreateDesktop -bool true && killall Finder
Best Answer
Go to Macintosh in the Finder. Once there be sure to display contents in icon view. Now while in Finder go to the View Menu and near the bottom select "Show view options". This brings up the panel shown below.
Move the top slider to the right for larger icons. You may have to move the grid slider to increase spacing as well. You can experiment with these two sliders to get the default view you want.