Last active
February 18, 2024 21:15
-
-
Save mjackson/6d0748fe44687877d3e44e0ef9172c9b to your computer and use it in GitHub Desktop.
Quickly show/hide desktop icons on macos
This file contains 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 | |
# To install: just copy this script to your machine and name it whatever you want. | |
# Let's say you named it toggle-desktop-icons.sh, then all you need to do is make | |
# the script executable, like this: | |
# | |
# chmod +x toggle-desktop-icons.sh | |
# | |
# Now you can execute the script directly in the terminal any time you want to | |
# show/hide the desktop icons, like this: | |
# | |
# ./toggle-desktop-icons.sh | |
prevValue=$(defaults read com.apple.finder CreateDesktop 2>&1) | |
nextValue=$([[ "$prevValue" == "true" || "$prevValue" == *"does not exist"* ]] && echo "false" || echo "true") | |
if [[ "$nextValue" == "true" ]]; then | |
echo "Showing desktop icons..." | |
else | |
echo "Hiding desktop icons..." | |
fi | |
defaults write com.apple.finder CreateDesktop $nextValue | |
killall Finder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MacOS 14 now has a preference for this 👌