Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Change theme with user.js file

  • 11 replies
  • 1 has this problem
  • 336 views
  • Paskiausią atsakymą parašė AMAN ARYAN

more options

Hi,

I'm trying to change the theme (only using standard dark and light themes) from a linux terminal. My attempted routes include changing a user.js file (the rest of the file works), in particular setting extensions.activeThemeID (I've also attempted doing this in about:config, as well as editing the extensions.json file).

I can change the theme by going to add-ons in a browser. This works fine. I was hoping to automate it (it's not the 1980's - clicking three times to change to a default theme seems unnecessary).

Am I missing something that must be changed in about:config or any other file to change the theme? The extensions.activeThemeID changes when changing the theme in add-ons and seems the likely option but does nothing if I change this value myself.

Hi, I'm trying to change the theme (only using standard dark and light themes) from a linux terminal. My attempted routes include changing a user.js file (the rest of the file works), in particular setting extensions.activeThemeID (I've also attempted doing this in about:config, as well as editing the extensions.json file). I can change the theme by going to add-ons in a browser. This works fine. I was hoping to automate it (it's not the 1980's - clicking three times to change to a default theme seems unnecessary). Am I missing something that must be changed in about:config or any other file to change the theme? The extensions.activeThemeID changes when changing the theme in add-ons and seems the likely option but does nothing if I change this value myself.

Chosen solution

It is possible that the extensions.activeThemeID pref (this pref is part of syncing prefs) is only used to sync the theme to other devices and that the Sync code handles selecting the theme.

Some places in the code that deal with themes:

Skaityti atsakymą kartu su kontekstu 👍 1

All Replies (11)

more options

Themes are a kind of add-on and their settings are stored in a JSON-format data file named extensions.json. What did you try editing there? The currently active theme has its active property set to true.

more options

In the relevant theme section I set active to true and userDisabled to false. I also changed the other theme active to false and userDisabled to true.

These seemed to be the options that differed depending on the theme in use.

more options

It looks like these settings change the button on about:addons as if the theme is enabled (i.e. it now says disable) but the theme doesn't change.

more options

eddiewh said

It looks like these settings change the button on about:addons as if the theme is enabled (i.e. it now says disable) but the theme doesn't change.

Are you trying to change the theme while Firefox is still running or between sessions? user.js is only read at startup. extensions.json may be read when the Add-ons page is loaded so it can reflect the current state of the file, but probably is only applied when read at startup.

If you need to make a change in real time, you probably have to run a script in the Browser Console (I don't know what the script would be, though).

more options

Thanks for the help jscher. I was trying to change it between sessions, but would be happy with it changing during.

It is reading user.js since the extensions.activeThemeID changes in about:config (it currently says firefox-compact-light@mozilla.org but the theme is dark). It is also reading extensions.json since the button changes state (it currently says disable for the light theme indicating it is in the enabled state and enable for the dark theme). I can restart Firefox (and change the configs with Firefox closed) and all these things remains exactly the same.

I think there is a missing link between these things and the actual theme being set which seems odd but I'm not knowledgeable enough to figure it out. Your account has got me to start looking into userChrome.css files which could be an alternative though.

more options

userChrome.css files are great for applying your own style rules, but unlikely to help with built-in themes.

I wonder how Firefox knows at startup which one to apply? Must be some other file we're not thinking of.

more options

To override builtin themes for specific pages you can consider to use code in userContent.css to override related CSS variables.

  • /questions/1282670 How to make the Start Page dark or black
  • resource://activity-stream/css/activity-stream.css
more options

Thanks cor-el. It was the whole theme which was not updating (toobar colours etc.), not just for specific pages.

It seems a strange issue to be honest. I would have thought that changing the extensions.activeThemeID in about:config would be designed to change the theme. However I'm no expert and I'm sure there is a reason why it doesn't or a simple alternative that I haven't found.

The userContent.css and userChrome.css files are definitely the way to go when customising Firefox anyway (a bit longer to set up than using a standard theme but definitely worth it in the long run) so the advice is appreciated. Automating changes in these files is a simple job.

more options

Chosen Solution

It is possible that the extensions.activeThemeID pref (this pref is part of syncing prefs) is only used to sync the theme to other devices and that the Sync code handles selecting the theme.

Some places in the code that deal with themes:

more options

From a brief look I think you've hit the nail on the head there, but I'm far too tired and not anywhere near being competent enough to start messing around with Firefox source code right now. I'll stick with the .css files for the time being and maybe take a look when I get a chance so I can mark this problem solved.

It's kind of beautiful that Firefox is open-source by the way.

Thanks for all the help cor-el and jscher. It's massively appreciated. I almost considered changing to google chrome for a moment when trying to get it running.

more options

Alright, it's sorted! I had a lwtheme folder where theme-header and-footer were stored, but for whatever reason I needed to have the theme-header and -footer files outside of the folder too. I didn't have them! So, I transferred them over from the new profile I created to my old profile and presto! Then the preview wasn't working but I found this and solved that problem too - http://www.hazelstutorials.com/firefox-personas-mouseoverhover-not-working/#comment-8779 Thanks again everyone!