Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/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"
profilePath="$appRoot/$name.app/Contents/Profile"
plistPath="$appRoot/$name.app/Contents/Info.plist"
# make the directories
mkdir -p "$resourcePath" "$execPath" "$profilePath"
# 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
exec "$chromePath" --app="$url" --user-data-dir="$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>CFBundleExecutable</key>
<string>$name</string>
<key>CFBundleIconFile</key>
<string>icon</string>
</dict>
</plist>
EOF
@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills Jan 6, 2012

Gmail works quite well in this and copy/paste images works. Nice! Thanks much.

Gmail works quite well in this and copy/paste images works. Nice! Thanks much.

@guyjz

This comment has been minimized.

Show comment Hide comment
@guyjz

guyjz Apr 25, 2012

Hmm.. this works great for the dock icon, but doesn't affect the icon that appears when command-tabbing between apps.

guyjz commented Apr 25, 2012

Hmm.. this works great for the dock icon, but doesn't affect the icon that appears when command-tabbing between apps.

@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills Apr 25, 2012

It does, but it's not consistent. It reverts after a while. I haven't locked down when it comes back except for after a reboot. I tend to leave it running for long periods of time. If I think about it and notice a pattern I'll add it to this.

On a different note, is there any way to get the address bar to show? I didn't notice anything in the script that looked like it should disable it. Maybe something is needed in the plist. This is a minor minor minor issue. If you have some ideas on what to look at I can search for it.

It does, but it's not consistent. It reverts after a while. I haven't locked down when it comes back except for after a reboot. I tend to leave it running for long periods of time. If I think about it and notice a pattern I'll add it to this.

On a different note, is there any way to get the address bar to show? I didn't notice anything in the script that looked like it should disable it. Maybe something is needed in the plist. This is a minor minor minor issue. If you have some ideas on what to look at I can search for it.

@demonbane

This comment has been minimized.

Show comment Hide comment
@demonbane

demonbane May 3, 2012

I've had that same thing happen from time to time. It appears to be related to opening new tabs/new windows within that session, but I can't consistently replicate it. Sometimes it falls back to the standard Chrome icon and other times it doesn't.

Owner

demonbane commented May 3, 2012

I've had that same thing happen from time to time. It appears to be related to opening new tabs/new windows within that session, but I can't consistently replicate it. Sometimes it falls back to the standard Chrome icon and other times it doesn't.

@guyjz

This comment has been minimized.

Show comment Hide comment
@guyjz

guyjz May 3, 2012

It consistently doesn't work for me at all. I.e. the icon in the app-switching overlay when command-tabbing invariably shows only the generic chrome icon. Which makes it very annoying and difficult to navigate using the keyboard between several such apps...

I'm using chrome 19 (beta) in case that makes any difference.

guyjz commented May 3, 2012

It consistently doesn't work for me at all. I.e. the icon in the app-switching overlay when command-tabbing invariably shows only the generic chrome icon. Which makes it very annoying and difficult to navigate using the keyboard between several such apps...

I'm using chrome 19 (beta) in case that makes any difference.

@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills May 3, 2012

Perhaps. Mine was generated with one of the versioni 18 builds. It always starts at least with the new icon. Have you gone back to the app with get info and pasted in the icon you want to use?

Perhaps. Mine was generated with one of the versioni 18 builds. It always starts at least with the new icon. Have you gone back to the app with get info and pasted in the icon you want to use?

@guyjz

This comment has been minimized.

Show comment Hide comment
@guyjz

guyjz May 3, 2012

How can I paste an icon there if it was created from a png file?

It already appears fine in the get info box: http://cl.ly/3p2L271n2o0c3P3E3t1t

guyjz commented May 3, 2012

How can I paste an icon there if it was created from a png file?

It already appears fine in the get info box: http://cl.ly/3p2L271n2o0c3P3E3t1t

@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills May 3, 2012

Does it work as a standard Chrome application shortcut?

Does it work as a standard Chrome application shortcut?

@guyjz

This comment has been minimized.

Show comment Hide comment
@guyjz

guyjz May 3, 2012

guyjz commented May 3, 2012

@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills May 3, 2012

Which would make sense. I actually didn't know about Chrome application shortcuts until I did a little digging around and saw it available. But for Windows. Not for Mac. Of course. Which is why this gist is here. :) If the site is public I could try it out on my build and let you know if it works. Is it asana.com? And is that .png around somewhere? (OT: asana.com looks pretty neat if that is the one you're looking to use.)

Which would make sense. I actually didn't know about Chrome application shortcuts until I did a little digging around and saw it available. But for Windows. Not for Mac. Of course. Which is why this gist is here. :) If the site is public I could try it out on my build and let you know if it works. Is it asana.com? And is that .png around somewhere? (OT: asana.com looks pretty neat if that is the one you're looking to use.)

@guyjz

This comment has been minimized.

Show comment Hide comment
@guyjz

guyjz May 3, 2012

guyjz commented May 3, 2012

@michaelwills

This comment has been minimized.

Show comment Hide comment
@michaelwills

michaelwills May 3, 2012

Must be something about the build of Chrome you're on then. That worked for me. The icon shows up in the app switcher with command-tab, shows up in Alfredapp's app list when typing asa…, etc.

Must be something about the build of Chrome you're on then. That worked for me. The icon shows up in the app switcher with command-tab, shows up in Alfredapp's app list when typing asa…, etc.

@sanfordredlich

This comment has been minimized.

Show comment Hide comment
@sanfordredlich

sanfordredlich Jan 18, 2013

Aha, the problem is that some people are using input images that aren't square.

This should fix the problem:
sips -s format tiff $icon --out $resourcePath/icon.tiff --resampleHeightWidth 128 128 >& /dev/null

I created a gist of the fixed version:
https://gist.github.com/4568525

Thanks for the script!

Aha, the problem is that some people are using input images that aren't square.

This should fix the problem:
sips -s format tiff $icon --out $resourcePath/icon.tiff --resampleHeightWidth 128 128 >& /dev/null

I created a gist of the fixed version:
https://gist.github.com/4568525

Thanks for the script!

@schmurfy

This comment has been minimized.

Show comment Hide comment
@schmurfy

schmurfy Jan 25, 2013

That's awesome thanks for sharing this !
I started to use application shortcuts on windows a while ago and was really unhappy not to be able to use them on my mac.

That's awesome thanks for sharing this !
I started to use application shortcuts on windows a while ago and was really unhappy not to be able to use them on my mac.

@nine9ths

This comment has been minimized.

Show comment Hide comment
@nine9ths

nine9ths Feb 1, 2013

Does the result of this script store cookies separately from the main chrome app as you can do with the paid version of Fluid or are they shared?

nine9ths commented Feb 1, 2013

Does the result of this script store cookies separately from the main chrome app as you can do with the paid version of Fluid or are they shared?

@sanfordredlich

This comment has been minimized.

Show comment Hide comment
@sanfordredlich

sanfordredlich Feb 2, 2013

@nine9ths: it looks like they're separate, I have to lot in to each

@nine9ths: it looks like they're separate, I have to lot in to each

@larki

This comment has been minimized.

Show comment Hide comment
@larki

larki May 21, 2013

Hi, great script! I have one problem though (besides the icon sometimes resetting to the standard chrome icon): I would like to assign the app to a specific desktop. To do that you can right click on the icon in the dock, go to options and choose "This desktop". This works for every app, except for the one created with your script...it doesn't give me the option "this desktop". Any idea how to fix this?

larki commented May 21, 2013

Hi, great script! I have one problem though (besides the icon sometimes resetting to the standard chrome icon): I would like to assign the app to a specific desktop. To do that you can right click on the icon in the dock, go to options and choose "This desktop". This works for every app, except for the one created with your script...it doesn't give me the option "this desktop". Any idea how to fix this?

@plattenschieber

This comment has been minimized.

Show comment Hide comment
@plattenschieber

plattenschieber Jul 17, 2013

Hey, good job! Unfortunately it doesn't work for Chrome Extensions, like the Any.Do app. It opens the "oops, couldn't open.." window. First I thought it might be the string being handled wrong, so I hard coded it into the script and could even see the right URL in the Menubar while loading. But again "oops.." Any thoughts about it?


Edit: my fault - of course it doesn't work. The created app is not aware of any installed extensions, because it's working with a new profile. I had to install the extension to the newly created profile.

Hey, good job! Unfortunately it doesn't work for Chrome Extensions, like the Any.Do app. It opens the "oops, couldn't open.." window. First I thought it might be the string being handled wrong, so I hard coded it into the script and could even see the right URL in the Menubar while loading. But again "oops.." Any thoughts about it?


Edit: my fault - of course it doesn't work. The created app is not aware of any installed extensions, because it's working with a new profile. I had to install the extension to the newly created profile.

@demonbane

This comment has been minimized.

Show comment Hide comment
@demonbane

demonbane Aug 7, 2013

This has been updated. I added @sanfordredlich's fix for non-square images and also added the ability to use an app name with spaces in it.

Owner

demonbane commented Aug 7, 2013

This has been updated. I added @sanfordredlich's fix for non-square images and also added the ability to use an app name with spaces in it.

@dep

This comment has been minimized.

Show comment Hide comment
@dep

dep Aug 27, 2013

This works great but sometimes the App icon gets lost and the Chrome icon will show up in its place. Very odd. Though looks like this issue is already well mentioned here.

dep commented Aug 27, 2013

This works great but sometimes the App icon gets lost and the Chrome icon will show up in its place. Very odd. Though looks like this issue is already well mentioned here.

@ivotron

This comment has been minimized.

Show comment Hide comment
@ivotron

ivotron Oct 6, 2013

One of the ways of consistently losing the customized icon is by downloading a file or invoking the "open file" dialog. I reported the issue here:

https://code.google.com/p/chromium/issues/detail?id=302884

ivotron commented Oct 6, 2013

One of the ways of consistently losing the customized icon is by downloading a file or invoking the "open file" dialog. I reported the issue here:

https://code.google.com/p/chromium/issues/detail?id=302884

@patrickoshaughnessey

This comment has been minimized.

Show comment Hide comment
@patrickoshaughnessey

patrickoshaughnessey Dec 9, 2013

The problem I am encountering with the app shortcuts created with this script is that my main Google Chrome installation thinks that it is already running when one of the app shortcuts is running, so it will not launch. Maybe there is a setting for Chrome that allows for multiple copies of Chrome to run simultaneously?

The problem I am encountering with the app shortcuts created with this script is that my main Google Chrome installation thinks that it is already running when one of the app shortcuts is running, so it will not launch. Maybe there is a setting for Chrome that allows for multiple copies of Chrome to run simultaneously?

@eerne

This comment has been minimized.

Show comment Hide comment
@eerne

eerne Jan 2, 2014

If profile data is stored within the application itself it is not possible for non-admin users to run it. Changed the script https://gist.github.com/eerne/8222446 to store the profile data in the users home directory at "~/Library/Application Support/<appname>/<randomnumber>/".

eerne commented Jan 2, 2014

If profile data is stored within the application itself it is not possible for non-admin users to run it. Changed the script https://gist.github.com/eerne/8222446 to store the profile data in the users home directory at "~/Library/Application Support/<appname>/<randomnumber>/".

@jacopocolo

This comment has been minimized.

Show comment Hide comment
@jacopocolo

jacopocolo Jan 30, 2014

Just, thank you. I've been struggling with Fluid.app for days because it's user agent does not support Wunderlist. With this script I created a wunderlist standalone app in 1 minute. Thank you so much.

Just, thank you. I've been struggling with Fluid.app for days because it's user agent does not support Wunderlist. With this script I created a wunderlist standalone app in 1 minute. Thank you so much.

@viraf

This comment has been minimized.

Show comment Hide comment
@viraf

viraf Feb 11, 2014

Is there a way to get notifications & app name in the menubar working ?

viraf commented Feb 11, 2014

Is there a way to get notifications & app name in the menubar working ?

@lydudlejning

This comment has been minimized.

Show comment Hide comment
@lydudlejning

lydudlejning Apr 15, 2014

Sorry to ask stupid questions. but how do I make an app out of that code?

Sorry to ask stupid questions. but how do I make an app out of that code?

@eLinkLocal

This comment has been minimized.

Show comment Hide comment
@eLinkLocal

eLinkLocal Apr 16, 2014

You can follow this video on Lifehacker, but download the script here and extract it. It's a good idea to create a folder called "Scripts" and place things like this in there. I also have a subfolder called App Icons. Basically you extract file, open terminal and follow the video instructions. http://lifehacker.com/5611711/create-application-shortcuts-in-google-chrome-for-mac-with-a-shell-script

You can follow this video on Lifehacker, but download the script here and extract it. It's a good idea to create a folder called "Scripts" and place things like this in there. I also have a subfolder called App Icons. Basically you extract file, open terminal and follow the video instructions. http://lifehacker.com/5611711/create-application-shortcuts-in-google-chrome-for-mac-with-a-shell-script

@nathanbirrell

This comment has been minimized.

Show comment Hide comment
@nathanbirrell

nathanbirrell Jul 23, 2014

is there any way to have chrome to open new windows in a tab? not liking the 'new window' bit...

is there any way to have chrome to open new windows in a tab? not liking the 'new window' bit...

@kevnk

This comment has been minimized.

Show comment Hide comment
@kevnk

kevnk Sep 17, 2014

Thanks so much for this—now I can use chrome extensions in a FluidApp-esque fasion! Good work!

kevnk commented Sep 17, 2014

Thanks so much for this—now I can use chrome extensions in a FluidApp-esque fasion! Good work!

@kevinnguy

This comment has been minimized.

Show comment Hide comment
@kevinnguy

kevinnguy Dec 28, 2014

Thanks for the awesome script! Does anyone know how to make the tab bar show in the ssb? Using this to make a standalone Gmail :)

Thanks for the awesome script! Does anyone know how to make the tab bar show in the ssb? Using this to make a standalone Gmail :)

@AnthonyDiSanti

This comment has been minimized.

Show comment Hide comment
@AnthonyDiSanti

AnthonyDiSanti Feb 6, 2015

The instructions still say that the app name can't include spaces while that's no longer true

The instructions still say that the app name can't include spaces while that's no longer true

@kylamct

This comment has been minimized.

Show comment Hide comment
@kylamct

kylamct Mar 3, 2015

why does this open in a different profile? how can I get it to open in my default profile?

Thanks!!

kylamct commented Mar 3, 2015

why does this open in a different profile? how can I get it to open in my default profile?

Thanks!!

@lkingsella

This comment has been minimized.

Show comment Hide comment
@lkingsella

lkingsella Apr 4, 2015

This is a great script! I would like to use 1Password within the app. Could anyone suggest how I can install the add-in. I can't get an address bar to go to the site. (I know that is the point of the script.) Thank you.

This is a great script! I would like to use 1Password within the app. Could anyone suggest how I can install the add-in. I can't get an address bar to go to the site. (I know that is the point of the script.) Thank you.

@nhodges

This comment has been minimized.

Show comment Hide comment
@nhodges

nhodges Apr 14, 2015

@lkingsella Open your app, press CMD + N (or CTRL + N on Windows) to open a new window with the same profile, then install the 1Password extension.

nhodges commented Apr 14, 2015

@lkingsella Open your app, press CMD + N (or CTRL + N on Windows) to open a new window with the same profile, then install the 1Password extension.

@lkingsella

This comment has been minimized.

Show comment Hide comment
@lkingsella

lkingsella Apr 15, 2015

@nhodges, THANK YOU!

@nhodges, THANK YOU!

@victor-torres

This comment has been minimized.

Show comment Hide comment
@victor-torres

victor-torres Sep 14, 2015

Thank you! Just what I was looking for. Now I can use WhatsApp web as an 'application'.
I've used this script to make a GUI: https://github.com/victor-torres/quickwebapp.

Thank you! Just what I was looking for. Now I can use WhatsApp web as an 'application'.
I've used this script to make a GUI: https://github.com/victor-torres/quickwebapp.

@75th

This comment has been minimized.

Show comment Hide comment
@75th

75th Nov 17, 2015

Is there a way to get notifications & app name in the menubar working ?

Ditto both these questions.

75th commented Nov 17, 2015

Is there a way to get notifications & app name in the menubar working ?

Ditto both these questions.

@JoyceBabu

This comment has been minimized.

Show comment Hide comment
@JoyceBabu

JoyceBabu Jan 19, 2016

@lydudlejning

  1. Click on the 'Raw' button. Download and save the file to your Desktop.
  2. Open Terminal.app
  3. In terminal prompt, make the file executable by running the following command (copy paste the command and hit return key)
    chmod +x ~/makeapp.sh
  4. Execute the script
    ~/makeapp.sh

@lydudlejning

  1. Click on the 'Raw' button. Download and save the file to your Desktop.
  2. Open Terminal.app
  3. In terminal prompt, make the file executable by running the following command (copy paste the command and hit return key)
    chmod +x ~/makeapp.sh
  4. Execute the script
    ~/makeapp.sh
@muesliq

This comment has been minimized.

Show comment Hide comment
@muesliq

muesliq Aug 4, 2016

Great script! But how do I prevent links to open in that new app instead of the standard chrome profile? If all links I open in my new Gmail app open there instead of my browser that kind of defeats the purpose of such an app. Any ideas? Can I force links to open in my standard Chrome profile?

muesliq commented Aug 4, 2016

Great script! But how do I prevent links to open in that new app instead of the standard chrome profile? If all links I open in my new Gmail app open there instead of my browser that kind of defeats the purpose of such an app. Any ideas? Can I force links to open in my standard Chrome profile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment