Tuesday, October 18, 2016

Hide that cluttered desktop on your Mac

A silly hidden feature allows to disable the rendering of desktop icons on Mac OS X (and macOS Sierra). Just put it in a shell file and make it executable. This script basically toggles the hidden boolean setting. For more detailed information on why one would want to hide desktop icons, please see http://osxdaily.com/2009/09/23/hide-all-desktop-icons-in-mac-os-x/.

#!/bin/bash
# Toggles the "rendering" of items on the MacOS X desktop (keep a clean look).
# For more info, see http://osxdaily.com/2009/09/23/hide-all-desktop-icons-in-mac-os-x/
set -u

CMD_READ_V="defaults read com.apple.finder CreateDesktop"
CMD_WRITE_V="defaults write com.apple.finder CreateDesktop -bool "

RET=$(${CMD_READ_V} 2> /dev/null)
[ $? = 1 ] && ENABLED=1 || ENABLED=${RET}
if [ ${ENABLED} = 1 ]; then
  ${CMD_WRITE_V} false
else
  ${CMD_WRITE_V} true
fi
killall Finder

No comments:

Post a Comment