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"
45 tell app "System Events" to display dialog "$@" buttons "Bummer" default button 1 with icon 0 with title "Installation Error"
47 ) </dev/null >/dev/null 2>&1 &
51 cd "$SRC" || error "The 'Screen Savers' folder does not exist.
53 You can't copy the installer out of the Disk Image!"
56 free=`df -k "$DSTVOLUME" |
57 tail -1 | head -1 | awk '{print $4}'`
58 need=`echo $REQUIRED_SPACE \* 1024 | bc`
59 if [ "$free" -lt "$need" ]; then
60 free=`echo $free / 1024 | bc`
61 error "Not enough disk space: $free MB available, $REQUIRED_SPACE MB required."
65 mkdir -p "$DST1" || error "Unable to create directory $DST1/"
66 mkdir -p "$DST2" || error "Unable to create directory $DST2/"
68 # Install the savers in /System/Library/Screen Savers/
72 echo "Installing $DD" >&2
73 rm -rf "$DD" || error "Unable to delete $DD"
74 cp -pr "$f" "$DST1/" || error "Unable to install $f in $DST1/"
75 xattr -r -d com.apple.quarantine "$DD"
77 # If this saver is also installed in the per-user directory,
78 # delete that copy so that we don't have conflicts.
80 if [ "$DEBUG" = 0 ]; then
86 # Install the apps in /Applications/
90 echo "Installing $DD" >&2
91 rm -rf "$DD" || error "Unable to delete $DD"
92 cp -pr "$f" "$DST2/" || error "Unable to install $f in $DST2/"
93 xattr -r -d com.apple.quarantine "$DD"
96 # Launch System Preferences with the Screen Saver pane selected.
98 open /System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane &