├── README.md └── chrome-ssb.sh /README.md: -------------------------------------------------------------------------------- 1 | chrome-ssb 2 | ========== 3 | 4 | 2015-08-19 UPDATE: Mac users may want to check out [Epichrome](https://github.com/dmarmor/epichrome) or [MacPin](https://github.com/kfix/MacPin) for an actively developed SSBs on OS X. I am also beginning work on a [pyssb](https://github.com/lhl/pyssb), a PyQT5-based SSB project (focused for my personal use on Arch Linux, but it could be cross-platform if anyone wanted to contribute). I'm happy to merge any updates, but otherwise, consider this project deprecated. 5 | 6 | --- 7 | 8 | Simple script for making Chrome SSBs on OS X 9 | 10 | This is an update of [Bracken King](https://twitter.com/brackenthebox)'s original script published in [this 2010 article](http://www.lessannoyingcrm.com/articles/149/Create_application_shortcuts_in_Google_Chrome_on_a_Mac). 11 | 12 | I've updated it a bit to work better: 13 | * Allow spaces in all variables 14 | * Properly Trim spaces for easy drag and dropping of icon paths 15 | * Properly look for Chrome location in /Applications (it uses the first one it finds) 16 | * Make the new App wherever it's called from 17 | * Your Profile is placed in the correct location (in the Bundle) no matter where you move the app 18 | 19 | ## Usage 20 | * Place chrome-ssb.sh in your path or somewhere convenient to call from 21 | * Run chrome-ssb.sh wherever you want 22 | * You can also move the created app anywhere you want without issues 23 | 24 | **Note:** Finder may not pick up the icon (shows up as invisible) if you have the creation target folder active/open. You can make it show up by moving the App to a different folder. If you know a workaround, please send a pull request... 25 | 26 | ## Notes 27 | * This script now makes a copy of the 'Google Chrome' launcher executable stub at application start (it is pretty small, about 13KB) instead of symlinking to solve 10.9 compatibility issues (see #22). The executable points to a specific version of the Google Chrome Framework (../Versions/[VERSION]/Google Chrome Framework.framework/Google Chrome Framework). 28 | * Copying the launcher executable instead of symlinking will break OS X Gatekeeper's code signing. This shouldn't normally be a problem, but is discussed in depth in Issue #23 29 | 30 | ## TODO 31 | * Better Icon Processing 32 | * http://www.amnoid.de/icns/makeicns.html 33 | * http://superuser.com/questions/133784/manipulate-mac-os-x-file-icons-from-automator-or-command-line 34 | 35 | ## License 36 | Do as you will 37 | -------------------------------------------------------------------------------- /chrome-ssb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # White Space Trimming: http://codesnippets.joyent.com/posts/show/1816 5 | trim() { 6 | local var=$1 7 | var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters 8 | var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters 9 | /bin/echo -n "$var" 10 | } 11 | 12 | 13 | ### Get Input 14 | /bin/echo "What should the Application be called?" 15 | read inputline 16 | name=`trim "$inputline"` 17 | 18 | /bin/echo "What is the url (e.g. https://www.google.com/calendar/render)?" 19 | read inputline 20 | url=`trim "$inputline"` 21 | 22 | /bin/echo "What is the full path to the icon (e.g. /Users/username/Desktop/icon.png)?" 23 | read inputline 24 | icon=`trim "$inputline"` 25 | 26 | 27 | #### Find Chrome. If its not in the standard spot, try using spotlight. 28 | chromePath="/Applications/Google Chrome.app" 29 | if [ ! -d "$chromePath" ] ; then 30 | chromePath=`mdfind "kMDItemCFBundleIdentifier == 'com.google.Chrome'" | head -n 1` 31 | if [ -z "$chromePath" ] ; then 32 | /bin/echo "ERROR. Where is chrome installed?!?!" 33 | exit 1 34 | fi 35 | fi 36 | chromeExecPath="$chromePath/Contents/MacOS/Google Chrome" 37 | 38 | # Let's make the app whereever we call the script from... 39 | appRoot=`/bin/pwd` 40 | 41 | # various paths used when creating the app 42 | resourcePath="$appRoot/$name.app/Contents/Resources" 43 | execPath="$appRoot/$name.app/Contents/MacOS" 44 | profilePath="$appRoot/$name.app/Contents/Profile" 45 | plistPath="$appRoot/$name.app/Contents/Info.plist" 46 | versionsPath="$appRoot/$name.app/Contents/Versions" 47 | 48 | # make the directories 49 | /bin/mkdir -p "$resourcePath" "$execPath" "$profilePath" 50 | 51 | # convert the icon and copy into Resources 52 | if [ -f "$icon" ] ; then 53 | if [ ${icon: -5} == ".icns" ] ; then 54 | /bin/cp "$icon" "$resourcePath/icon.icns" 55 | else 56 | sips -s format tiff "$icon" --out "$resourcePath/icon.tiff" --resampleHeightWidth 128 128 >& /dev/null 57 | tiff2icns -noLarge "$resourcePath/icon.tiff" >& /dev/null 58 | fi 59 | fi 60 | 61 | # Save a symlink to the location of the Chrome executable to be copied when the SSB is started. 62 | /bin/ln -s "$chromeExecPath" "$execPath/Chrome" 63 | 64 | ### Create the wrapper executable 65 | /bin/cat >"$execPath/$name" < "$plistPath" < 76 | 77 | 78 | 79 | CFBundleExecutable 80 | $name 81 | CFBundleName 82 | $name 83 | CFBundleIconFile 84 | icon.icns 85 | NSHighResolutionCapable 86 | True 87 | KSProductID 88 | com.google.Chrome.$name 89 | CFBundleIdentifier 90 | com.google.Chrome.$name 91 | 92 | 93 | EOF 94 | 95 | ### link the Versions directory 96 | /bin/ln -s "$chromePath/Contents/Versions" "$versionsPath" 97 | 98 | ### create a default (en) localization to name the app 99 | /bin/mkdir -p "$resourcePath/en.lproj" 100 | /bin/cat > "$resourcePath/en.lproj/InfoPlist.strings" <