Two scripts for mangling a Mozilla theme

Please notice that this is document rather old and the method it describes is - of course - a hack.

Adjusting the colouration of a Mozilla theme can be is a tedious task - there are literally more than half a thousand files to modify. Not something you want to do by hand.

Personally I'd like the Modern theme to have less colour - so I threw two scripts together to automate the process.

Requirements are: ImageMagick's convert, perl and bash or another decent shell.

Step by step

Find the .jar-file of the theme you want to modify. I used /usr/lib/mozilla/chrome/modern.jar.

Copy the jar-file to some dir you'll use as a work-dir. I used /usr/lib/mozilla/chrome/modern-auto. Download and unpack the two scripts in the same dir.

Find the ImageMagick convert-command line you'd like to apply. I took a screenshot of Mozilla with the Gimp and experimented on the screenshot until I found a command-line that suited me: "convert -modulate 120,15,105".

Modify the script fixup - change ORIGJAR, JAR and CONVERT to reflect the name of your original jar-file, the resulting jar-file and the command you want to apply.

Run ./fixup.

After running a new .jar-file will be placed in the working dir. Overwrite the .jar-file that Mozilla uses with the new one (I copied /usr/lib/mozilla/chrome/modern-auto/modern.jar to /usr/lib/mozilla/chrome/modern.jar) and restart Mozilla.


Here's what the Modern theme (Mozilla 0.8.1) looks like:

Here's what "convert -modulate 100,15,105" changes it into:

But I think a little lighter would be nice, so I tried (-modulate 120,15,105):

And here's a more radical change (-modulate 100,100,120):

Oh, wait, you didn't like purple? Try this one: (-modulate 100,100,20):

Or this pretty beast: (-modulate 120,140,5):

And one could go on (a lot of other options for "convert" are possible too of course, consult the man-page to learn more).

How does it work?

Converting all the .gif-files is simple - just find them and let ImageMagick do what it does. No problem.

But a the colours of a theme aren't solely defined in the 600+ .gif-files - colours are also in the .css files, and ImageMagick doesn't know how to handle that. That's where my second script comes in - it scans the css-files and makes a dummy .xpm-image every time a colour is encountered. ImageMagick is then invoked om the dummy .xpm, producing a converted .xpm from which the script extracts the new colour and inserts it into the .css-file. A simple hack.

Oh, the script reads /usr/X11R6/lib/X11/rgb.txt to convert text-names for colours to hex-codes. If rgb.txt isn't found, some colours in the .css-files may not be converted correctly.

(By the way: The throbber-animation isn't touched by the scripts).


mangle-0.0.tar.gz - the scripts.


Adam Sjøgren.

Feel free to email comments, improvements and patches :-)

0.0046 s