2 # XScreenSaver, Copyright © 2013-2014 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
23 REQUIRED_SPACE=160 # MB. Highly approximate.
25 export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PATH"
28 echo "XScreenSaver Installer: Error: $@" >&2
30 # Using "System Events" says "No user interaction allowed" on 10.9.
31 # But using "Automator Runner" still seems to work.
33 tell app "Automator Runner" to \
38 with title "Installation Error"
40 ) </dev/null >/dev/null 2>&1 &
44 #if[ x"$DSTVOLUME" = x ]; then error "DSTVOLUME unset"; fi
45 if [ x"$PACKAGE_PATH" = x ]; then error "PACKAGE_PATH unset"; fi
46 if [ x"$HOME" = x ]; then error "HOME unset"; fi
49 echo "Destination: $DSTVOLUME" >&2
51 if [ x"$USER" = xjwz ]; then DEBUG=1; fi
53 if [ "$DEBUG" != 0 ]; then DSTVOLUME=/tmp; fi
55 SRC=`dirname "$PACKAGE_PATH"`/"Screen Savers"
56 DST1="$DSTVOLUME/Library/Screen Savers"
57 DST2="$DSTVOLUME/Applications"
58 PU="$DSTVOLUME/$HOME/Library/Screen Savers"
59 UPDATER="XScreenSaverUpdater.app"
61 cd "$SRC" || error "The 'Screen Savers' folder does not exist.
63 You can't copy the installer out of the Disk Image!"
66 free=`df -k "$DSTVOLUME" |
67 tail -1 | head -1 | awk '{print $4}'`
68 need=`echo $REQUIRED_SPACE \* 1024 | bc`
69 if [ "$free" -lt "$need" ]; then
70 free=`echo $free / 1024 | bc`
71 error "Not enough disk space: $free MB available, $REQUIRED_SPACE MB required."
75 mkdir -p "$DST1" || error "Unable to create directory $DST1/"
76 mkdir -p "$DST2" || error "Unable to create directory $DST2/"
78 # Install the savers and the updater in /System/Library/Screen Savers/
79 # Install the other apps in /Applications/
81 for f in *.{saver,app} ; do
82 EXT=`echo "$f" | sed 's/^.*\.//'`
83 if [ "$EXT" = "app" -a "$f" != "$UPDATER" ]; then
89 echo "Installing $DD" >&2
90 rm -rf "$DD" || error "Unable to delete $DD"
91 cp -pR "$f" "$DST/" || error "Unable to install $f in $DST/"
93 # Eliminate the "this was downloaded from the interweb" warning.
94 xattr -r -d com.apple.quarantine "$DD"
96 if [ "$EXT" = "app" ]; then
97 # Eliminate the "this is from an unknown developer" warning.
101 # If this saver or app is also installed in the per-user directory,
102 # delete that copy so that we don't have conflicts.
104 if [ "$DEBUG" = 0 ]; then
109 # Launch System Preferences with the Screen Saver pane selected.
111 open /System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane &