Last active
February 3, 2019 15:14
-
-
Save dzogrim/0912d62b360195fc70517293d03f83fc to your computer and use it in GitHub Desktop.
De/activate macOS Desktop icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## This tool will de/activate macOS Desktop icons | |
| ##-- dzogrim < dzogrim [@] dzogrim [.] pw > | |
| #VERSION="1.0 (2015-03-24)" | |
| ##-- * Activate or hide OS X Desktop (and icons) | |
| # =============================================== | |
| # Configuration | |
| # =============================================== | |
| NAME=$(basename $0) | |
| #-- Customized colors | |
| export cRST='\033[0m' \ | |
| cRed='\033[31;1m' cDRed='\033[31m' cRedBG='\033[41;1m' cDRedBG='\033[41m' \ | |
| cGreen='\033[32;1m' cDGreen='\033[32m' cGreenBG='\033[42;1m' cDGreenBG='\033[42m' \ | |
| cBlue='\033[34;1m' cDBlue='\033[34m' cBlueBG='\033[44;1m' cDBlueBG='\033[44m' \ | |
| cYellow='\033[33;1m' cDYellow='\033[33m' cYellowBG='\033[43;1m' cDYellowBG='\033[43m' \ | |
| cMagenta='\033[35;1m' cDMagenta='\033[35m' cMagentaBG='\033[45;1m' cDMagentaBG='\033[45m' \ | |
| cCyan='\033[36;1m' cDCyan='\033[36m' cCyanBG='\033[46;1m' cDCyanBG='\033[46m' \ | |
| cWhite='\033[37;1m' cBright='\033[37;1m' cGrey='\033[37m' cGreyBG='\033[47m' \ | |
| cWhiteBG='\033[47;1m' cBrightBG='\033[47;1m' | |
| #-- Find 'echo' program in PATH or use Mac Ports default location | |
| ECHO="$( which echo )" | |
| ECHO="${ECHO:-/opt/local/libexec/gnubin/echo}" | |
| #-- Bash version check for 'echo' | |
| [ -n "${BASH_VERSION}" ] \ | |
| && ECHO="echo -e" \ | |
| || ECHO="echo" | |
| # =============================================== | |
| # Functions | |
| # =============================================== | |
| LogINFO() | |
| { | |
| ${ECHO} " ${cGreen}*${cRST} $*" | |
| } | |
| # =============================================== | |
| LogWARN() | |
| { | |
| ${ECHO} " ${cYellow}*${cRST} $*" >&2 | |
| } | |
| # =============================================== | |
| LogERROR() | |
| { | |
| ${ECHO} " ${cRed}* [ERROR]${cRST} $*" >&2 | |
| } | |
| # =============================================== | |
| hideMyDesktopOrReverse() | |
| { | |
| [ -z "${OPERATOR}" ] && usage | |
| defaults write com.apple.finder CreateDesktop -bool "${OPERATOR}"; killall Finder | |
| } | |
| # =============================================== | |
| usage() | |
| { | |
| ${ECHO} "" | |
| LogWARN "This will terminate Finder, make sure no operation are running." | |
| ${ECHO} "" | |
| LogINFO "To activate :" | |
| ${ECHO} " ${NAME} ON" | |
| LogINFO "To deactivate and hide icons:" | |
| ${ECHO} " ${NAME} OFF" | |
| exit 0 | |
| } | |
| # =============================================== | |
| # Main | |
| # =============================================== | |
| #-- Usage | |
| [ "$1" = "" ] && usage | |
| [ "$1" = "ON" ] && OPERATOR="true" | |
| [ "$1" = "OFF" ] && OPERATOR="false" | |
| hideMyDesktopOrReverse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment