Skip to content

Instantly share code, notes, and snippets.

@BoQsc
Last active July 16, 2019 08:50
Show Gist options
  • Save BoQsc/51d34efdf2593d94443c4d4ff3e4e2c4 to your computer and use it in GitHub Desktop.
Save BoQsc/51d34efdf2593d94443c4d4ff3e4e2c4 to your computer and use it in GitHub Desktop.
Downloads Firefox Extension and Extracts into Firefox Extensions Folder. For the extension to become enabled, it is required for firefox to be restarted twice. After running Firefox for the first time, Firefox will scan for extensions in the extensions folder. After second time the Firefox is ran, Firefox will enable the extension. To automate t…
#!/bin/bash
if [ "$USER" != "root" ]; then exec sudo bash "$0" "$@"; fi
# Download Latest "Gnome-Shell Integration Extension" for Firefox Browser.
#_________________________________________________________________________
wget "https://addons.mozilla.org/firefox/downloads/latest/gnome-shell-integration/addon-898030-latest.xpi" \
--output-document="gnome_shell_integration-an+fx-linuz.xpi" \
-q --show-progress \
# Open Downloaded "Gnome-Shell Integration Extension" XPI file
#_________________________________________________________________________
## XPI files are .zip archives, we use "unzip" command to open it.
## -p extract files to pipe (stdout).
## And, we will output/extract manifest.json file content into a variable.
manifest_json_file=$(unzip -p "gnome_shell_integration-an+fx-linuz.xpi" "manifest.json")
# We will parse manifest file for ID value
extensionId=$(echo $manifest_json_file | grep -Po '"id": *\K"[^"]*"')
# Remove Quotes from the Json ID value
extensionId=$( echo $extensionId | tr -d '"')
# Rename the extension to its ID from manifest.json file
mv "gnome_shell_integration-an+fx-linuz.xpi" "$extensionId.xpi"
mv "$extensionId.xpi" "/lib/firefox/browser/extensions/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment