-
-
Save eerne/8222446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "What should the Application be called (no spaces allowed e.g. GCal)?" | |
read inputline | |
name="$inputline" | |
echo "What is the url (e.g. https://www.google.com/calendar/render)?" | |
read inputline | |
url="$inputline" | |
echo "What is the full path to the icon (e.g. /Users/username/Desktop/icon.png)?" | |
read inputline | |
icon="$inputline" | |
chromePath="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" | |
appRoot="/Applications" | |
# various paths used when creating the app | |
resourcePath="$appRoot/$name.app/Contents/Resources" | |
execPath="$appRoot/$name.app/Contents/MacOS" | |
randDir=$(jot -r 1 10000000000 99999999999) | |
profilePath="Library/Application Support/$name/$randDir" | |
plistPath="$appRoot/$name.app/Contents/Info.plist" | |
# make the directories | |
mkdir -p "$resourcePath" "$execPath" | |
# convert the icon and copy into Resources | |
if [ -f "$icon" ] ; then | |
sips -s format tiff "$icon" --out "$resourcePath/icon.tiff" --resampleHeightWidth 128 128 >& /dev/null | |
tiff2icns -noLarge "$resourcePath/icon.tiff" >& /dev/null | |
fi | |
# create the executable | |
cat >"$execPath/$name" <<EOF | |
#!/bin/sh | |
if [ ! -d "\$HOME/$profilePath" ]; then | |
mkdir -p "\$HOME/$profilePath" | |
touch "\$HOME/$profilePath/First Run" | |
fi | |
exec "$chromePath" --app="$url" --user-data-dir="\$HOME/$profilePath" "\$@" | |
EOF | |
chmod +x "$execPath/$name" | |
# create the Info.plist | |
cat > "$plistPath" <<EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" “http://www.apple.com/DTDs/PropertyList-1.0.dtd”> | |
<plist version=”1.0″> | |
<dict> | |
<key>CFBundleName</key> | |
<string>$name</string> | |
<key>CFBundleExecutable</key> | |
<string>$name</string> | |
<key>CFBundleIconFile</key> | |
<string>icon</string> | |
<key>CFBundleIdentifier</key> | |
<string>github.makeapp.$name</string> | |
</dict> | |
</plist> | |
EOF | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment