JAL-3393 Made an all-in-one script to create the DS_Store from scratch (has to be...
[jalview.git] / utils / install4j / mk_ds_store.sh
1 #!/usr/bin/env bash
2
3 NAME="Jalview"
4
5 TMPNAME="${NAME// /_}_Installer"
6 APPNAME="${NAME}.app"
7 DMG="${TMPNAME}.dmg"
8
9 WDIR=$(pwd)
10 cd /tmp
11 mkdir -p "$TMPNAME"
12 cd "$TMPNAME"
13 mkdir "$APPNAME"
14 ln -s /Applications " "
15 mkdir .background
16 mkdir .fseventsd
17 cp "${WDIR}/background.png" .background/background.png
18 cd /tmp
19 [ -e "$DMG" ] && rm "$DMG"
20 hdiutil create -volname "$TMPNAME" -srcfolder "$TMPNAME" -size 1m -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW "$DMG"
21 open "$DMG"
22
23 sleep 1
24
25 VOL="/Volumes/${TMPNAME}"
26 #osascript "${WDIR}/set_ds_store.applescript" "$TMPNAME" "$APPNAME"
27 osascript - "$TMPNAME" "$APPNAME" <<EOF
28 on run {volumeName, appName}
29         tell application "Finder"
30                 tell disk (volumeName as string)
31                         open
32                         
33                         set theXOrigin to 10
34                         set theYOrigin to 60
35                         set theWidth to 480
36                         set theHeight to 300
37                         
38                         set theBottomRightX to (theXOrigin + theWidth)
39                         set theBottomRightY to (theYOrigin + theHeight)
40                         
41                         tell container window
42                                 set current view to icon view
43                                 set toolbar visible to false
44                                 set statusbar visible to false
45                                 set pathbar visible to false
46                                 set bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY + 220}
47                                 set statusbar visible to false
48                                 set position of every item to {100, theBottomRightY + 150}
49                         end tell
50                         
51                         set opts to the icon view options of container window
52                         tell opts
53                                 set icon size to 76
54                                 set text size to 14
55                                 set label position to bottom    
56                                 set arrangement to not arranged
57                         end tell
58                         
59                         set background picture of opts to file ".background:background.png"
60                         
61                         set position of item (appName as string) to {133, 124}
62                         set position of item " " to {336, 124}
63
64                         tell container window
65                                 set bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
66                         end tell
67                         
68                         close
69                         open
70
71                         update every item
72                 end tell
73         end tell
74 end run
75 EOF
76
77 DSSTORE="${VOL}/.DS_Store"
78 until [ -e "$DSSTORE" ] && grep background.png "$DSSTORE"; do
79   sleep 1
80   echo "Waiting for \"$DSSTORE\" to update"
81 done
82
83 SAVED_DSSTORE="${TMPNAME}-DS_Store"
84 cp "$DSSTORE" "${WDIR}/${SAVED_DSSTORE}"
85 echo "Created new .DS_Store as \"$SAVED_DSSTORE\""
86
87 umount "$VOL"
88 cd /tmp
89 rm "$DMG"
90 rm -r "/tmp/${TMPNAME}"
91
92 cd "$WDIR"
93