Jump to content
ShogunPanda

alfred-chrome - Open URL in Google Chrome (also with specific profile)

Recommended Posts

Also available here: http://www.packal.org/workflow/alfred-chrome

 

Introduction

 

This workflow allows you to open a URL in Google Chrome.

 

To trigger the workflow, type chrome or cr. Optionally you can add a URL.

Between the results you will a list of profiles to use to open the URL (or simply to open a new window).

If you hold the `Alt` key while selecting the result item, the window will be open using incognito mode.

 

Installation
 
Double click (or open in Alfred settings) the Alfred Chrome.alfredworkflow file.

This workflow is for Alfred 3 only therefore it works on macOS 10.9+ (Mavericks and following).

 
Uninstallation
 
Remove the workflow via Alfred settings.

 

Specifying a different flavor of Chrome

 

If you use Canary version of Chrome or similar applications, like Chromium, you can instruct the workflow to use it.

To do it:

 

  1. In the Workflows settings, select Alfred Chrome workflow.
  2. Open the Configure workflow and variables by clicking on the second icon on right section of the workflow header.
  3. Under the Workflow Environment Variables section, create a variable called ALFRED_CHROME_NAME and enter the same name you see in your Applications folder.
  4. Click on Save and you're good to go! :)
Edited by ShogunPanda

Share this post


Link to post

Possibly dumb question - my Google Profile names have spaces in them...is there somewhere else I should be looking to get the Profile name? (For example, they are called "Matt Gmail" and "Matt Chef")

Share this post


Link to post

Don't know if it's possible but can the script be update to allow just opening the browser, not an url is required, else the workflow just does nothing.

 

For example when I do "chrome as Chris" i would like chrome to open/switch to chrome with my "Chris" profile active

Share this post


Link to post

Ehi @polen, do you get any error or notification?

 

If not, can you please try the following steps and paste the output here?

 

1. Open Alfred Preferences 
2. Go to Workflows settings 
3. Right click on “Alfred Chrome” and then click on “Open in terminal” 
4. Press enter in the terminal 
5. Type “./alfred-chrome $QUERY“ (without quotes, where $QUERY must be replaced with whatever you usually type in Alfred) and press enter again 
 

This way I should be able to address any issue. Thanks!

  Paolo

Share this post


Link to post

I don't get any notification. When I run it in the terminal I get dyld: Library not loaded: @rpath/libswiftAppKit.dylib  ...  :(

 

 

 

 

 

 

 

 

Share this post


Link to post

Hi all!

I’ve updated the workflow again. The main executable in the workflow (which now is 2.3 MB instead of the previous 354 KB) now uses static linking. 

This means the error @polen sent me should be gone and even on older macOS the workflow should work

Can you please download it again and confirm it?

Thanks!

Share this post


Link to post

I'm having some trouble with this workflow. When I enter "chrome in $USER $URL" I get an invalid url message. "chrome $URL" works fine.

 

Where would I track down the correct variable for $USER? Profile names doesn't seem to work, and neither does the folder names in the Chrome application support folder.

Share this post


Link to post
On 30/1/2017 at 7:28 PM, santip said:

Hi @ShogunPanda, any chance you can share the source code of the "alfred-chrome" executable on github?

 

Thanks!

 

Ehm... it was in the .gitignore file by mistake. Fixed now.

Edited by ShogunPanda

Share this post


Link to post

Hi all.

I just published version 3. This one simplifies usage buy only requiring "chrome" or "cr" to be typed to show all available profiles.

You can also insert the URL or toggle incognito using the Alt key.

See the first post for more informations.

Share this post


Link to post

Hi,
Getting an error while trying to initialize the shortcut
Error logs when 
“./alfred-chrome $cr“ from terminal,

-bash: “./alfred-chrome: No such file or directory

 

Error logs in application window,
 

Starting debug for 'Alfred Chrome'

[2017-04-16 22:18:15][ERROR: input.scriptfilter] Code 1: Google Chrome cannot be found.
Nothing to do! :(
[2017-04-16 22:18:15][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Google Chrome cannot be found.
Nothing to do! :(


I am syncing Alfred preferences via Dropbox

Share this post


Link to post

The same for me

 

On 4/16/2017 at 8:04 PM, doctorwho said:

Error logs in application window,


Starting debug for 'Alfred Chrome'

[2017-04-16 22:18:15][ERROR: input.scriptfilter] Code 1: Google Chrome cannot be found.
Nothing to do! :(
[2017-04-16 22:18:15][ERROR: input.scriptfilter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Google Chrome cannot be found.
Nothing to do! :(

 

Edited by artdev

Share this post


Link to post

I also get the same error.

Google Chrome cannot be found.
Nothing to do! :(

After changing the application name to "Google Chrome Canary" it worked though, just not with the normal version.

Edited by aheidelberg

Share this post


Link to post

Hi there ... I have been unable to launch the script with the same errors as above ... in terminal

Google Chrome cannot be found. Nothing to do! :(

All good if you're too busy to fix it.

 

Many thanks

Share this post


Link to post

@loudestnoise Download only the main.swift file from my GitHub. Then compile it to an executable on your Mac either with Xocde or in Terminal.app by running

swiftc main.swift -o alfred-chrome-fixed

or whatever output name you want. I'm not sure if you need to install Xcode for that.

 

Then right click on Alfred Chrome in the Alfred Workflows Tab to open the workflow directory in Finder. Copy the compiled executable there and change the script Alfred Chrome is using by right-clicking the "cr" and / or "chrome" Script Filter, then Configure Object and then changing the Script File to your new file.

That's what I did, hope it helps.

Edited by aheidelberg

Share this post


Link to post

Hi all!

First of all, sorry for the long absence in supporting this workflow.

@aheidelberg Thanks for finding a workaround while I was MIA :)

 

Today I've update the Workflow to version 4.0.0.

This update includes a rewrite in Go of the helper, which slims down workflow size by more than a half.

I also checked Chrome source and I now the profiles detection has vastly improved, support explicitly Chrome, Chrome Canary and vanilla Chromium.

 

Finally, in order to specify a different Chrome flavor, you know have to use the environment variable ALFRED_CHROME_NAME, which you can easily edit in the workflow configuration window (second icon in the settings) rather than editing obscure files. 

For more information about this, checkout the first post of this thread.

 

Let me know if it works properly and thanks again for liking this!

See ya!

  Paolo

Share this post


Link to post

Any way to default open with incognito?

 

Also, it species to open with "Profile 1". Any way to change the name of the profile?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×