summaryrefslogtreecommitdiff
path: root/mac-Resources/postflight
blob: 87c83710a3b400335c16190e8e243797cf5e4e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#cd /usr/local/lib
#ln -s libgdraw.1.*.*.dylib libgdraw.1.dylib
#ln -s libgdraw.*.*.*.dylib libgdraw.dylib
#ln -s libgunicode.1.*.*.dylib libgunicode.1.dylib
#ln -s libgunicode.*.*.*.dylib libgunicode.dylib
#Mac OS/X 10.1 did not have plutil
if test -d ~/Library/Preferences -a -e /usr/bin/plutil ; then
  if test \! -e ~/Library/Preferences/com.apple.x11.plist ; then
    cat <<EOF >~/Library/Preferences/com.apple.x11.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>apps_menu</key>
	<array>
		<array>
			<string>Terminal</string>
			<string>xterm</string>
			<string>n</string>
		</array>
		<array>
			<string>FontForge</string>
			<string>/usr/local/bin/fontforge</string>
			<string>f</string>
		</array>
	</array>
</dict>
</plist>
EOF
    plutil -convert binary1 ~/Library/Preferences/com.apple.x11.plist
  elif grep -q fontforge ~/Library/Preferences/com.apple.x11.plist ; then
    cat </dev/null >/dev/null
# It's already in the menu, no need to add it
  else
    if grep -q "xml version=" ~/Library/Preferences/com.apple.x11.plist ; then
# It's already in xml format
      cp ~/Library/Preferences/com.apple.x11.plist /tmp/x11.xml
    else
      plutil -convert xml1 -o /tmp/x11.xml ~/Library/Preferences/com.apple.x11.plist
    fi
    if grep -q apps_menu ~/Library/Preferences/com.apple.x11.plist ; then
      cat >/tmp/fontforge-sed-script <<EOF
/apps_menu/ { N
a \\
		<array>\\
			<string>FontForge</string>\\
			<string>/usr/local/bin/fontforge</string>\\
			<string>f</string>\\
		</array>
}
EOF
    else
      cat >/tmp/fontforge-sed-script <<EOF
/<dict/ a \\
	<key>apps_menu</key>\\
	<array>\\
		<array>\\
			<string>Terminal</string>\\
			<string>xterm</string>\\
			<string>n</string>\\
		</array>\\
		<array>\\
			<string>FontForge</string>\\
			<string>/usr/local/bin/fontforge</string>\\
			<string>f</string>\\
		</array>\\
	</array>
EOF
    fi
    sed -f /tmp/fontforge-sed-script /tmp/x11.xml >/tmp/x11_1.xml
    plutil -convert binary1 -o ~/Library/Preferences/com.apple.x11.plist /tmp/x11_1.xml
    rm -f /tmp/x11_1.xml /tmp/fontforge-sed-script /tmp/x11.xml
  fi
fi
exit 0