Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Showing and hiding all desktop icons via the command line

$
0
0

As part of preparing for a presentation, it’s often handy to be able to hide the icons on your desktop so that folks viewing the presentation aren’t distracted by what you have stored on your desktop.

To aid with this, there are defaults commands which can be run to hide or (if hidden) show the icons on your desktop.

To hide your desktop’s icons, run the command shown below:

defaults write com.apple.finder CreateDesktop -bool false

To show your desktop’s icons, run the command shown below:

defaults write com.apple.finder CreateDesktop -bool true

After running the appropriate command to either show or hide the desktop’s icons, the Finder needs to be restarted so that it can display the changes. You can do this one of two ways:

1. Log out, then log back in
2. Run the following command:

killall Finder

Since I usually remember only at the last minute that I should hide my desktop icons, I’ve also built an Automator application named Show or Hide Desktop Icons.app to assist me with showing or hiding my own desktop’s icons. For more details, see below the jump.

Using Show or Hide Desktop Icons.app

1. If needed, download the Show_and_Hide_Desktop_Icons zip file from the installer directory in my GitHub repo.

2. Once downloaded and installed, double-click on the Show or Hide Desktop Icons application in /Applications.

Screen Shot 2016 06 26 at 12 57 24 PM

3. Depending on if your icons are visible or hidden, the following actions take place:

Visible icons:

  1. The defaults command to hide the icons is applied.
  2. The Finder process is restarted.
  3. A dialog window notifies you that the desktop icons are now hidden.

Screen Shot 2016 06 26 at 12 57 32 PM

Hidden icons:

  1. The defaults command to make the icons visible is applied.
  2. The Finder process is restarted.
  3. A dialog window notifies you that the desktop icons are now visible.

Screen Shot 2016 06 26 at 12 57 47 PM

How Show or Hide Desktop Icons.app works

Show or Hide Desktop Icons.app is an Automator application that uses shell scripting behind the scenes to run the needed commands. When the application is launched, the following process takes place:

The script inside the Automator application determines if the desktop icons are set to be hidden or visible by checking for the following conditions:

Condition:

The CreateDesktop value in the user’s ~/Library/Preferences/com.apple.finder.plist file is either not explicitly set or set with a boolean value of true.

Action:

  1. The defaults command to hide the icons is applied.
  2. The Finder process is restarted.
  3. A dialog window notifies you that the desktop icons are now hidden.
  4. The script exits.

Condition:

The CreateDesktop value in the user’s ~/Library/Preferences/com.apple.finder.plist file is set with a boolean value of false.

Action:

  1. The defaults command to make the icons visible is applied.
  2. The Finder process is restarted.
  3. A dialog window notifies you that the desktop icons are now visible.
  4. The script exits.

The shell script inside looks like this:

The total workflow looks like this:

Screen Shot 2016 06 26 at 4 14 21 PM

For those interested, all Show or Hide Desktop Icons.app components and scripts are available via the GitHub repo linked below:

https://github.com/rtrouton/Show-or-Hide-Desktop-Icons



Viewing all articles
Browse latest Browse all 764

Trending Articles