Skip to content

Instantly share code, notes, and snippets.

@stefansundin
Last active May 16, 2024 07:39
Show Gist options
  • Save stefansundin/c89fd15bae5a58831790 to your computer and use it in GitHub Desktop.
Save stefansundin/c89fd15bae5a58831790 to your computer and use it in GitHub Desktop.
Create Chrome apps in Mac OS.
#!/bin/sh
# wget https://gist.githubusercontent.com/stefansundin/c89fd15bae5a58831790/raw/make-chrome-app.sh
# chmod +x make-chrome-app.sh
# ./make-chrome-app.sh
echo "Note that the app will run with a separate data dir and thus not have your regular extensions and settings."
echo
echo "What should the app be called?"
read name
echo
if [ -d "$HOME/Applications/$name.app" ]; then
echo "That app already exists."
exit 1
fi
echo "What is the url?"
read url
echo
echo "What is the full path to the icon? (optional)"
read icon
chrome="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
app="$HOME/Applications/$name.app/Contents"
mkdir -p "$app/Resources" "$app/MacOS" "$app/Profile"
# convert the icon
if [ -f $icon ]; then
sips -s format tiff $icon --out "$app/Resources/icon.tiff" --resampleWidth 128 &> /dev/null
tiff2icns -noLarge "$app/Resources/icon.tiff" &> /dev/null
fi
# create the executable
cat > "$app/MacOS/$name" <<EOF
#!/bin/sh
exec "$chrome" --app="$url" --user-data-dir="$app/Profile" --disable-save-password-bubble "\$@"
EOF
chmod +x "$app/MacOS/$name"
# create Info.plist
cat > "$app/Info.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>$name</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
</plist>
EOF
# disable Chrome's first-run dialog
touch "$app/Profile/First Run"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment