2 # XScreenSaver, Copyright © 2013 Jamie Zawinski <jwz@jwz.org>
4 # Permission to use, copy, modify, distribute, and sell this software and its
5 # documentation for any purpose is hereby granted without fee, provided that
6 # the above copyright notice appear in all copies and that both that
7 # copyright notice and this permission notice appear in supporting
8 # documentation. No representations are made about the suitability of this
9 # software for any purpose. It is provided "as is" without express or
12 # The guts of the installer. Copies the screen savers out of the adjacent
13 # "Screen Savers" directory and into "/Library/Screen Savers/". We do it
14 # this way instead of just including the screen savers in the package
15 # because that would double the size of the DMG.
17 # Created: 27-Jul-2013.
19 #exec >/tmp/xscreensaver.log 2>&1
22 REQUIRED_SPACE=140 # MB. Highly approximate.
26 if [ x"$USER" = xjwz ]; then
30 echo "Destination: $DSTVOLUME" >&2
32 if [ "$DEBUG" != 0 ]; then
36 SRC=`dirname "$PACKAGE_PATH"`/"Screen Savers"
37 DST1="$DSTVOLUME/Library/Screen Savers"
38 DST2="$DSTVOLUME/Applications"
39 PU="$DSTVOLUME/$HOME/Library/Screen Savers"
40 UPDATER="XScreenSaverUpdater.app"
46 tell app "System Events" to display dialog "$@" buttons "Bummer" default button 1 with icon 0 with title "Installation Error"
48 ) </dev/null >/dev/null 2>&1 &
52 cd "$SRC" || error "The 'Screen Savers' folder does not exist.
54 You can't copy the installer out of the Disk Image!"
57 free=`df -k "$DSTVOLUME" |
58 tail -1 | head -1 | awk '{print $4}'`
59 need=`echo $REQUIRED_SPACE \* 1024 | bc`
60 if [ "$free" -lt "$need" ]; then
61 free=`echo $free / 1024 | bc`
62 error "Not enough disk space: $free MB available, $REQUIRED_SPACE MB required."
66 mkdir -p "$DST1" || error "Unable to create directory $DST1/"
67 mkdir -p "$DST2" || error "Unable to create directory $DST2/"
69 # Install the savers in /System/Library/Screen Savers/
72 for f in *.saver "$UPDATER" ; do
74 echo "Installing $DD" >&2
75 rm -rf "$DD" || error "Unable to delete $DD"
76 cp -pR "$f" "$DST1/" || error "Unable to install $f in $DST1/"
77 xattr -r -d com.apple.quarantine "$DD"
79 # If this saver is also installed in the per-user directory,
80 # delete that copy so that we don't have conflicts.
82 if [ "$DEBUG" = 0 ]; then
88 # Install the apps in /Applications/
89 # But not the updater.
92 if [ "$f" != "$UPDATER" ]; then
94 echo "Installing $DD" >&2
95 rm -rf "$DD" || error "Unable to delete $DD"
96 cp -pR "$f" "$DST2/" || error "Unable to install $f in $DST2/"
97 xattr -r -d com.apple.quarantine "$DD"
101 # Launch System Preferences with the Screen Saver pane selected.
103 open /System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane &