Sometimes it is helpful to hide all icons on a desktop, e.g. during a presentation or if you want to focus on something and the files on desktop are disturbing. The following shell script is a solution for Max OS X.
[code language=”bash”]
#!/bin/sh
if [ $1 = "true" ] || [ $1 = "false" ]
then
echo "setting desktop icons to $1"
defaults write com.apple.finder CreateDesktop -bool $1
killall -SIGHUP Finder
else
echo "usage: $0 [true|false]" 1>&2
fi
[/code]
This is a practical example on how shell programming can support daily routines (from our operating systems class). The other examples I mentioned during today’s class were about using shell programming for batch editing large amounts of video files or pdfs.