stubborn Firefox on Ubuntu 18.04.4 LTS Gnome

I have been using Ubuntu 18.04.4 LTS, with workspaces stacked vertically for some years. I like to open Firefox in the top workspace, but some two weeks ago this program started to behave oddly just after boot. It stubbornly opens in the third workspace from the top, even though I have the first one open. I always have to move it to the first workspace, but when I boot again and start Firefox, there it goes to the third one again.

Any ideas on how to fix this?


Solution 1:

Firefox has a config "widget.disable-workspace-management" that defaults to "false", i.e., Firefox does do some workspace management by default. Setting it to "true" fixes this problem for me. Here are the steps:

  1. Open Firefox.
  2. In the address bar (the place where you usually type in a URL), enter "about:config".
  3. You might need to accept a warning about changing preferences.
  4. In the "Search preference name" field, either put in the whole config name mentioned above, or just put in "workspace".
  5. In the result that comes up, widget.disable-workspace-management, it should show "false" by default. To toggle to "true", click on the double-arrow icon on the far right of the preference (if you hover over it, the status tip will say "Toggle".
  6. There is no "save" you need to do. Your change applies immediately.

If you prefer, you can change this preference on the command line (this is nice if you use a setup script that sets up your applications how you like them when you do a fresh install of your operating system). To do this:

  1. Make sure no instance of Firefox is running (otherwise the change could be overwritten).

  2. Find the prefs.js file that corresponds to your Firefox profile. One way to find it is to first do sudo updatedb and then locate -b "\prefs.js". In the results, pick the one that looks like it corresponds to your profile. For me, the correct file is the following: ~/.mozilla/firefox/main/prefs.js.

  3. Then, you can append the config into that file. Using the filename above, the command would be the following:

    echo 'user_pref("widget.disable-workspace-management", true);' >> mozilla/firefox/main/prefs.js

Here is an attempt at a fully automated command. It may or may not work for you:

if pgrep -x "firefox" > /dev/null; then
    echo "ERROR: Should not modify config while Firefox is running." >&2
    echo "Please exit all Firefox instances and try again." >&2
else
  for d in ~/.mozilla/firefox/*; do
    if [ -e "${d}/prefs.js" ]; then
      echo 'user_pref("widget.disable-workspace-management", true);' >> "${d}/prefs.js"
    fi
  done
fi

I learned about this config value from "jamiemint" on his reply here. Thank you jamiemint!

Solution 2:

Firefox window size and location is saved in a file called xulstore.json in your Firefox profile directory.

To reset it find the file by running ( close Firefox first ):

find ~/.mozilla/firefox/ -type f -name "xulstore.json"

Then rename or delete the file or, alternatively, run the following command which will rename the file for you:

find ~/.mozilla/firefox/ -type f -name "xulstore.json" -exec mv {} {}.old \;

Then start Firefox.