How to install GNOME Shell Integration extension in the Chromium Browser via command-line?

Clarifications:

  1. The .crx extension installation that I am inquiring about must take place in the Chromium Browser, not Google-Chrome Browser.
  2. The methodologies stated in the references mentioned by @pomsky to my earlier question only worked for Google-Chrome Browser. The original documentation for those methodologies is given here
  3. I have written a python script to implement points 2 & 6 of the "Using preference file" methodology (see below code which must be executed with administrator privilege). I confirm it installed the "GNOME Shell Integration" package in the Google Chrome browser. However, it did not work for the Chromium browser.
  4. I am looking for a solution for the Chromium browser.
  5. Originally, the system only had Chromium Browser. The Google Chrome browser was later installed to test the hypothesis that my script would work with it and not the Chromium browser. So presently my system has both browsers installed.

Code:

#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
from pathlib import Path
from json import loads, dump
def installChromeExtension( extensionID): extension = Path( '/opt/google/chrome/extensions/' ) extension.mkdir( mode=0o777, parents=True, exist_ok=True ) preferences_file = extension/str( extensionID + '.json' ) preferences_file.touch() data = { 'external_update_url' : ' } with preferences_file.open( "w" ) as file: dump( data, file, indent=4 ) print( f'Created {preferences_file}.')
GNOME_Shell_Integration_id = 'gphhapmejobijbbhgpjhcjognlahblep'
installChromeExtension( GNOME_Shell_Integration_id ) 

According to Chromium's webpage on "Chrome Extension Developer FAQ for upcoming changes in May 2015 related to hosting extensions FAQ 8" : What are the supported deployment options for extensions after this change?:

For OSX and Linux, extensions can be installed via a preferences JSON file.

I am searching for a similar documentation for Chromium.

1

1 Answer

1. Background

According to Chromium documentation, there appear to be three approaches to installing .crx extensions. Namely, via Group Policy, via the Registry, or via master_preferences For Linux, the Registry method does not seem appropriate (it seems to be for Windows system). Also, it states that:

Using policy to deploy an Extension or Chrome Web App is by far the easiest and scalable method.

This other documentation also discussed the consideration for using Preferences over Policy methodologies and recommended to:

Prefer policies to configure Chrome on managed computers. Use recommended policies for settings that users should be able to change, and use mandatory policies for settings that users should not be able to change. A master_preferences file may be used to make default settings for new users, though doing so has some drawbacks:

I have not been able to install the "GNOME Shell Integration" extension via the Preferences method. The good news is that I found out how to use the Policy method to install this extension in Chromium. I have described it below.

2. Installing Extension via Policy Method

Chromium does have Linux Quick Start writeup on the Policy method. Note:

  1. For Chromium browser you need to replace /etc/opt/chrome with /etc/chromium in their example else your extensions won't appear.

  2. You need to put your policy file in /etc/chromium/policies/managed else it won't work. I did try using /etc/chromium/policies/recommended and it did not work. Putting the policy file into the managed directory also means that your extension cannot be removed by the user.

  3. Your policy file needs to use policy name ExtensionInstallForcelist.

3. Steps to install GNOME Shell Integration Extension in Chromium from Cmdline:

  1. Run these commands in the terminal. The file my_policy.json can be any name you like, but it must be a .json file.

    $ sudo mkdir -p /etc/chromium/policies/managed
    $ sudo touch /etc/chromium/policies/managed/my_policy.json
    $ gedit admin:///etc/chromium/policies/managed/my_policy.json
  2. Add these lines into my_policy.json:

    { "ExtensionInstallForcelist": [ "gphhapmejobijbbhgpjhcjognlahblep;", ],
    }
  3. According to the GNOME Shell Integration Extension, "You MUST install native connector for this extension to work". A detailed list of commands to install the native connector is give here. For Ubuntu, do:

    $ sudo apt-get install chrome-gnome-shell
  4. Close all Chromium browsers and start the Chromium browser afresh.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like