Created
March 29, 2013 21:28
-
-
Save chales/5273789 to your computer and use it in GitHub Desktop.
Google Chrome app creation script for OS X. I found a post on LifeHacker with a similar script so I used that to work out the icon creation which I was having issues with.
This file contains hidden or 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 | |
# Local application path. The default is /Applications but I tend to separate | |
# my apps in the sub directories, e.g. /Applications/Internet | |
app_root="/Applications" | |
path_chrome="$app_root/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | |
# Everything below should be good as is, the script is interactive. | |
# 1 Name | |
# 2 URL | |
# 3 Icon | |
######################################################################## | |
# Name your app | |
echo "Name the application with no spaces (e.g. Chrome-Gmail or Chrome_Gmail)" | |
read app_name | |
# URL this app will run | |
echo "App Url (e.g. https://mail.google.com/mail/ca/u/0/#inbox)" | |
read app_url | |
# Icon for the app | |
echo "Application icon path (e.g. /Users/{user}/Pictures/gmail-app_icon.jpg)" | |
echo "(Hint: you can just drag and drop it on the terminal)" | |
read app_icon | |
# Resource paths | |
path_exec="$app_root/$app_name.app/Contents/MacOS" | |
path_plist="$app_root/$app_name.app/Contents/Info.plist" | |
path_profile="$app_root/$app_name.app/Contents/Profile" | |
path_resources="$app_root/$app_name.app/Contents/Resources" | |
# Create the directories | |
mkdir -p $path_exec $path_profile $path_resources | |
# Create the app and make it executable | |
cat > $path_exec/$app_name <<EOF | |
#!/bin/sh | |
exec $path_chrome --app="$app_url" --user-data-dir="$path_profile" "\$@" | |
EOF | |
chmod +x $path_exec/$app_name | |
# Convert the app_icon with sips and copy it into Resources | |
# This was figured out by looking at the lifehacker script | |
if [ -f $app_icon ] ; then | |
sips -s format tiff $app_icon --out $path_resources/icon.tiff --resampleWidth 128 >& /dev/null | |
tiff2icns -noLarge $path_resources/icon.tiff >& /dev/null | |
fi | |
# Create the Info.plist | |
cat > $path_plist <<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>CFBundleExecutable</key> | |
<string>$app_name</string> | |
<key>CFBundleIconFile</key> | |
<string>icon</string> | |
</dict> | |
</plist> | |
EOF | |
# Done, show the app. | |
open $app_root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment