Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Latest commit

 

History

History
196 lines (136 loc) · 10.9 KB

README.md

File metadata and controls

196 lines (136 loc) · 10.9 KB

Firefox Selection Fix – Click will no longer select all in your URL bar

A script that disables the broken clickSelectsAll behavior of Firefox.

See this answer on Super User for full context and an explanation of the script.

What is this script for?

Various browsers have started adopting a particular behavior when clicking the address bar: the entire URL is selected. This goes against good UX practices. In Firefox, there used to be the preferences browser.urlbar.clickSelectsAll, browser.urlbar.update1, and browser.urlbar.update2 to control this behavior and other updates, but the latter two were always expected to be temporary.

Around March 2020, the browser.urlbar.clickSelectsAll preference has been removed. Since then, this bug has been under discussion, where a patch has been suggested — this would involve recompiling Firefox from scratch. As the clickSelectsAll doesn’t work” duplicates accumulate on Bugzilla, one of these has received a comment by Stephen McCarthy which describes a workaround that involves editing internal Firefox files. This workaround looks like the simplest approach, but the approach doesn’t work as-is.

This repo provides a script that attempts to give us users the browser.urlbar.clickSelectsAll = false experience back.

Where does this script work?

The script works for me. 😉 And I’m running Firefox Nightly on Arch Linux. This is the software setup that I’ve tested — it may work for other setups, too, and this script is likely to work with later versions as well:

  • Firefox Nightly 81.0a1 (2020-08-20) through 86.0a1 (2021-01-10) (64-bit)

Note: the versions will only be updated for substantial changes to the script.

How to run the script?

The script applies changes to a specific Firefox install path; it needs to be executed after each update of that Firefox install path. It should not be executed a second time before another Firefox update.

The script automatically modifies the browser/omni.ja file, and clears the browser’s startup cache and creates a .purgecaches file, in order to assure that the changes are properly applied when starting Firefox.

This step-by-step guide describes default script execution, i.e. without any options passed; you can pass options listed below.

Also see my Super User answer for detailed steps.

Before using the script for the first time

  1. Download the script.
  2. Set the script as a runnable file.

Before running the script

  1. Update Firefox and start Firefox so it installs all the updates properly.
  2. Close Firefox.

Running the script

  1. Execute the script.

    • Interactively: Either click it in your file manager, then click the “Run in terminal” button, or run it directly as e.g. bash ./fixfx-selection.sh.
    • Non-interactively: Click it in your file manager, then click the “Run” button.

    Interactive execution is recommended.

  2. The script should find your Firefox (and Firefox ESR) install path(s) automatically. If multiple viable paths are found, you can select the one you want to fix. If no paths are found, you can either

    • call the script with the --firefox option, specifying the Firefox install path, or
    • edit the script and put the correct path where it says Fallback path (near the top of the script).

    The correct path contains a browser directory with an omni.ja in it.

  3. The script checks if you have write access to all relevant directories: the Firefox install path, the backup path, and /tmp, where the unzipping happens. If not, you’ll be asked to enter your root password. You can also run the script with sudo instead.

  4. A backup of the internal application resources (browser/omni.ja) of your Firefox installation is created (in /tmp, by default).

  5. After a few moments, you should be able to launch Firefox normally. If everything went well, you should now be able to launch a fixed Firefox with an improved URL bar selection behavior (and search bar, too)! Press Enter to exit.

  6. However, if Firefox won’t run properly, close Firefox, and restore the backup by typing r and Enter. The backup will be restored and the script will exit. Start Firefox again to go back to normal.

Let me know if something went wrong, by creating a new issue. Provide details about terminal output, your system setup, and your software versions.

Since this script partially relies on Firefox making sure to use the newly changed browser/omni.ja, as opposed to a cached omni.ja file, additional care must be taken to make issues reproducible. See the wiki about the startup cache to gain insight into the cache clearing mechanism.

Restoring the backup

The script offers an opportunity to test Firefox and restore the backup in case something went wrong. It also tells you which file paths are being used and tells you the command lines for restoring the backup, if not already applied.

If you need to restore the backup later on, you can type commands into the terminal which are based on the following snippet. Check if you need to run this as root, and double-check the file paths.

firefox_dir=$(whereis -b firefox | cut -d ' ' -f 2)  # Or put the correct path here, like the `Fallback path` line in the script.
                                                     # `cut -d ' ' -f 2` just takes the first path found, which may not be the right one.
cp -p /tmp/omni-n.ja~ "$firefox_dir/browser/omni.ja" # Replace `n` by the incremental number of the backup file name.
touch "$firefox_dir/browser/.purgecaches"

Options in detail

As usual, short options can be combined, e.g. -qb '/tmp' which expands into -q -b '/tmp'. A -- marks the end of options, meaning every option after that will be ignored. There are no positional arguments for this script, so in fact, after --, everything is ignored.

  • -f PATH, --firefox PATH

    Picks PATH as the Firefox install path that is to be fixed.

    Note that PATH must include a browser/omni.ja file. If this validation fails, the script terminates.

    Omit this option to let the script find all firefox or firefox-esr paths on your system, validate them, and pick the one directory that is found. If more than one viable directory is found, the script will ask for selection of a specific directory (unless -q or --quiet is passed).

  • -b PATH, --backup PATH

    Stores backup of internal Firefox file browser/omni.ja in PATH.

    If PATH points to a directory, an incremental file name like omni-0.ja~, omni-1.ja~, etc. is used within that directory. If PATH points to an existing file, the file is overwritten with the backup. If the path name of PATH (without the file name) points to a directory, but the file name doesn’t point to an existing file, the backup is stored with that file name.

    Omitting this option defaults to /tmp with incremental backups.

  • -q, --quiet

    Only errors (specifically, anything echo’d to STDERR) will be logged. Normal (STDOUT) output will be suppressed. This will also suppress asking for confirmation.

    By default, output will be emitted, but if the script was not executed in an interactive terminal, all interactive selections or confirmation questions are suppressed, regardless of whether the --quiet option was passed or not. If confirmation questions are suppressed and the script finds more than one viable Firefox install path, it will automatically pick the most recently updated one. Note that these tests aren’t perfect and that they can break using some file descriptor redirection, but it should cover most basic cases of executing this script.

  • -h, -?, --help, --?

    If this option is present, the help information is printed, and the script exits.

Examples

We’ll assume that the script is callable via ./fixfx-selection.sh. The exact path and file name depends on where you placed the file.

  • The following command fixes a specific Firefox installation located under /usr/lib/firefox-de_DE and creates an incremental backup of the original omni.ja in /tmp. The specified directory must contain a browser/omni.ja.

    ./fixfx-selection.sh --firefox /usr/lib/firefox-de_DE
  • This command fixes an automatically determined Firefox installation, while creating a backup of browser/omni.ja in the specified directory. The file names are incremental, e.g. omni-0.ja~, omni-1.ja~, etc.

    ./fixfx-selection.sh -b /home/user/backups/my_backup_directory
  • This command fixes an automatically determined Firefox installation, while creating a backup of browser/omni.ja at the specified file name (if its containing directory exists). The file is overwritten, if it exists.

    ./fixfx-selection.sh -b /home/user/backups/my_omni_backup.ja~

Exit status

The script distinguishes between four different status codes when exiting. Error codes (i.e. status codes greater than 0) are usually accompanied by an error message printed to STDERR.

  • 0 for success: everything went as expected, the script terminated successfully.
  • 1 for general failure due to utilities used in the script: e.g. some file was not found, some directory could not be created, directory navigation failed, unzipping or zipping the omni.ja failed, read or write permissions could not be granted, etc.
  • 2 for incorrect script usage: e.g. --backup or --firefox used without values, the specified Backup directory doesn’t point to a regular file or a target within an existing directory, the specified Firefox path is not a valid Firefox path, etc.
  • 130 if the script process was terminated (e.g. via Ctrl+C) or killed.