Jump to content
Pennyworth

'Open URL' in specific Google Chrome user profile

Recommended Posts

I use various Google Chrome user profiles ("People", per Chrome's parlance) to keep my personal and work browser environments separate. This means that if I open a Google Docs link tied to work on my personal Chrome user profile, then it will say "You don't have access". I therefore have to always make sure my active Chrome window is of the profile for which I'm logged into an account of.

 

At the same time, I have many simple Keyword --> Open URL workflows. How can I have an 'Open URL' action open not just in a specific browser, but a specific user profile of that browser? Is there a way to accomplish this?

Share this post


Link to post
4 minutes ago, Pennyworth said:

Is there a way to accomplish this?

 

Instead of using Alfred's Open URL action, you use a Run Script with Language = "/bin/bash" and put whatever command-line command is necessary to open a URL in your preferred profile.

Share this post


Link to post

Thank you @deanishe, this solved my issue! The formula is:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome {URL} --profile-directory={profile_ID}

Unfortunately the simpler 'open -a' command won't work when using the 'profile-directory' arg, hence the long application file path.

Share this post


Link to post

I should also add that using a scripting language to accomplish this is noticeably slower than Alfred's "native" 'Open URL' action. I wonder if this could be sped up somehow...

Share this post


Link to post

What does "noticeably slower" mean? It is, of course, slower. If it's a lot slower, then you may have misconfigured your shell.

Share this post


Link to post
Posted (edited)
2 minutes ago, deanishe said:

What does "noticeably slower" mean? It is, of course, slower. If it's a lot slower, then you may have misconfigured your shell.

 

"Noticeably" is probably an overstatement, but there's definitely a 1-2 second lag when opening URLs via /bin/bash instead of Alfred's native URL Opener (basically instantaneous).

Edited by Pennyworth

Share this post


Link to post
3 minutes ago, deanishe said:

Is it much faster if you use /usr/bin/open URL or leave off the --profile-directory argument?

 

I tried removing the '--profile-directory' argument from the bash script and it still lags by 2 seconds more than Alfred's Open URL action.

Share this post


Link to post
5 hours ago, deanishe said:

And is it also slow from your shell?

 

It takes about the same if I open a URL through the shell/Terminal directly or through the Alfred workflow/keyword.

Share this post


Link to post
7 hours ago, deanishe said:

Then the slowness is in the system–Chrome communication, and there's nothing you can do to speed it up.

 

Yes, seems that way. Makes me wonder how Alfred's workflow action can get the job done faster than the system.

Share this post


Link to post
4 hours ago, Pennyworth said:

Yes, seems that way. Makes me wonder how Alfred's workflow action can get the job done faster than the system.

 

I suspect it’s because Alfred already has a persistent connection to the shared NSWorkspace, whereas your command/script needs to establish a new one every time it's run.

 

I don’t understand much about the way the whole macOS application runtime works, but when scripting applications, establishing the initial connection typically takes quite a long time, and the subsequent commands execute very quickly in comparison.

 

Perhaps @Andrew could explain it better/correct me if I'm wrong.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...