Skip to content

Instantly share code, notes, and snippets.

@mayoff
Forked from chockenberry/finder_icons.sh
Created June 20, 2017 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayoff/b8556a61a1317f3a6a2b0d33095a0373 to your computer and use it in GitHub Desktop.
Save mayoff/b8556a61a1317f3a6a2b0d33095a0373 to your computer and use it in GitHub Desktop.
A simple shell script to turn the Finders desktop icons on and off
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
echo "Desktop icons are now turned off"
else
echo "Desktop icons are already off"
fi
elif [ "$1" = "on" ]; then
if [ $enabled -eq 1 ]; then
echo "Desktop icons are already on"
else
defaults delete com.apple.finder CreateDesktop
osascript -e 'tell application "Finder" to quit'
open -a Finder
echo "Desktop icons now turned on"
fi
elif [ "$1" = "status" ]; then
if [ $enabled -eq 1 ]; then
echo "Desktop icons are on"
else
echo "Desktop icons are off"
fi
else
echo "usage: `basename $0` ( on | off | status )"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment