Arch Linux Forums

Discussion forums for Arch Linux, a simple, lightweight linux distribution.

You are not logged in.

#1 2008-05-28 02:02:28

lyman
Member
From: China
Registered: 2008-01-13
Posts: 10
Website

thunderbrand - a script to brand thunderbird without recompiling

Hi, all

Prompted by firebrand I've written another piece of script which will brand thunderbird without recompiling. Enjoy.

Thanks to Bebo, your original script helps a lot.

Code:

#!/bin/sh
#
# thunderbrand a script to brand thunderbird without recompilation
#
# NOTE 1: It has only been tested on Thunderbird 2.x.
# NOTE 2: It will only work on "Mail/News" branded thunderbirds.
#
# This script replaces and changes (a few) files in an existing thunderbird 
# installation. Run it after a thunderbird installation or upgrade, and restart 
# thunderbird. The program icon may not be (visibly) replaced until your desktop 
# environment is restarted.
#
# To revert to the original Mail/News brand, simply reinstall thunderbird.
#
# Dependencies: curl, zip, unzip, imagemagick
#


THUNDERBIRDDIR=/usr/lib/thunderbird   # Where thunderbird's data files resides.
NEWICONSDIR=""                        # If empty, the script uses a temporary directory for the replacement icons.
                                      # If you want to avoid downloading the icons every time you rebrand thunderbird,
                                      # point NEWICONSDIR to a suitable directory.
SOURCEBASE="http://lxr.mozilla.org/seamonkey/source" # The URL under which the "other-licenses" directory resides.

CHROMEDIR=$THUNDERBIRDDIR/chrome            # Simply the thunderbird chrome directory.



die() {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            echo " is present but is not a file. Quitting."
            exit 1
        fi
    fi

    echo -n ": Downloading... "
    if curl -sS "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        exit 1
    fi
}



TEMPDIR=$(mktemp -d -t thunderbrand-work-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t thunderbrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "mozicon50.xpm"                "/other-licenses/branding/thunderbird/mozicon50.xpm?raw=1"
get_icon "mozicon16.xpm"                "/other-licenses/branding/thunderbird/mozicon16.xpm?raw=1"
get_icon "mozicon128.png"               "/other-licenses/branding/thunderbird/mozicon128.png?raw=1"
get_icon "icon64.png"                   "/other-licenses/branding/thunderbird/content/icon64.png?raw=1"
get_icon "about-thunderbird.png"        "/other-licenses/branding/thunderbird/content/about-thunderbird.png?raw=1"
get_icon "about-credits.png"            "/other-licenses/branding/thunderbird/content/about-credits.png?raw=1"
get_icon "thunderbird-watermark.png"    "/other-licenses/branding/thunderbird/content/aboutFooter.png?raw=1"
get_icon "thunderbird-wizard-badge.png" "/other-licenses/branding/thunderbird/content/aboutFooter.png?raw=1"
cp "$NEWICONSDIR/mozicon50.xpm" "$NEWICONSDIR/default.xpm"



echo -e "\033[1mBranding chrome/en-US.jar\033[0m"
echo -n " - Unzipping branding files in chrome/en-US.jar to temporary directory... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/en-US/branding/brand.dtd locale/en-US/branding/brand.properties && echo "Done." || die 1 "Failed."

for FILE in $TEMPDIR/locale/en-US/branding/* ; do
    sed -i 's|Mail/News Client|Mozilla Thunderbird|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
    sed -i 's|Mail/News|Thunderbird|g' "$FILE" && echo " - Successfully edited ${FILE}" || die 1 "Could not edit ${FILE}."
done

echo -n " - Replacing old branding files in chrome/en-US.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/en-US/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding chrome/messenger.jar\033[0m"
echo -n " - Making new branding icon structure in temporary directory... "
mkdir -p "$TEMPDIR/content/branding" || die 1 "Could not create $TEMPDIR/content/branding."
cp "$NEWICONSDIR"/{about-thunderbird.png,about-credits.png,thunderbird-wizard-badge.png,thunderbird-watermark.png,icon64.png} "$TEMPDIR/content/branding/" || die 1 "Could not copy new icons to $TEMPDIR/content/branding/."
echo "Done."
echo -n " - Replacing old branding icon structure in chrome/messenger.jar... "
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/messenger.jar" content/branding/* ) && echo "Done." || die 1 "Failed."



echo -e "\033[1mBranding icons\033[0m"
echo -n " - Replacing chrome/icons/default/default.xpm... "
cp "$NEWICONSDIR/default.xpm" $THUNDERBIRDDIR/chrome/icons/default/ && echo "Done." || die 1 "Failed."

echo -n " - Replacing chrome/icons/default/messengerWindow.xpm... "
cp "$NEWICONSDIR/default.xpm" $THUNDERBIRDDIR/chrome/icons/default/messengerWindow.xpm && echo "Done." || die 1 "Failed."

echo -n " - Replacing chrome/icons/default/messengerWindow16.xpm... "
cp "$NEWICONSDIR/mozicon16.xpm" $THUNDERBIRDDIR/chrome/icons/default/messengerWindow16.xpm && echo "Done." || die 1 "Failed."

echo -n " - Replacing branding icons in icons/... "
cp "$NEWICONSDIR"/{default.xpm,mozicon16.xpm,mozicon50.xpm} $THUNDERBIRDDIR/icons/ && echo "Done." || die 1 "Failed."

chmod 644 \
    $THUNDERBIRDDIR/chrome/icons/default/default.xpm \
    $THUNDERBIRDDIR/chrome/icons/default/messengerWindow.xpm \
    $THUNDERBIRDDIR/chrome/icons/default/messengerWindow16.xpm \
    $THUNDERBIRDDIR/icons/*
chown root:root \
    $THUNDERBIRDDIR/chrome/icons/default/default.xpm \
    $THUNDERBIRDDIR/chrome/icons/default/messengerWindow.xpm \
    $THUNDERBIRDDIR/chrome/icons/default/messengerWindow16.xpm \
    $THUNDERBIRDDIR/icons/*

echo -n " - Replacing /usr/share/pixmaps/thunderbird.png: "
convert "$NEWICONSDIR/default.xpm" /usr/share/pixmaps/thunderbird.png && echo "Done." || die 1 "Failed."
chmod 644 /usr/share/pixmaps/thunderbird.png 
chown root:root /usr/share/pixmaps/thunderbird.png

archlinux x86_64 on Fujitsu MG75X/V (T7250/4G/120G SSD/IntelX3100)

Offline

 

#2 2008-07-30 15:13:04

yodo
Member
From: Germany
Registered: 2008-02-02
Posts: 48

Re: thunderbrand - a script to brand thunderbird without recompiling

This script worked like a charm, but it does not anymore with thunderbird version 2.0.0.16.
Although the script runs without error, the icons are not replaced.
Does anyone have the same problem? Or maybe even an updated script?

Offline

 

#3 2008-08-06 09:06:42

andrek
Member
From: Poland
Registered: 2007-12-27
Posts: 27

Re: thunderbrand - a script to brand thunderbird without recompiling

I've got following error :

Code:

Branding icons
 - Replacing chrome/icons/default/default.xpm... Done.
 - Replacing chrome/icons/default/messengerWindow.xpm... Done.
 - Replacing chrome/icons/default/messengerWindow16.xpm... Done.
 - Replacing branding icons in icons/... Done.
 - Replacing /usr/share/pixmaps/thunderbird.png: convert: Improper image header `/tmp/thunderbrand-icon-Lq0g3bL7/default.xpm'.
convert: missing an image filename `/usr/share/pixmaps/thunderbird.png'.

Failed.

Offline

 

#4 2008-08-06 12:20:22

yodo
Member
From: Germany
Registered: 2008-02-02
Posts: 48

Re: thunderbrand - a script to brand thunderbird without recompiling

I also get this error now. Maybe the image file (.xpm) is damaged? I can't convert it manually.
Edit: I found the solution in the firebrand thread. You have to edit the "SOURCEBASE" in the thunderbrand script.

Code:

SOURCEBASE="http://mxr.mozilla.org/seamonkey/source"

is correct.

Last edited by yodo (2008-08-06 12:45:03)

Offline

 

#5 2008-12-07 06:31:37

litemotiv
Member
From: Molvania
Registered: 2008-08-01
Posts: 666

Re: thunderbrand - a script to brand thunderbird without recompiling

You will also have to change THUNDERBIRDDIR from /usr/lib/thunderbird to /usr/lib/thunderbird-2.0

Last edited by litemotiv (2008-12-07 06:31:53)

Offline

 

#6 2009-09-11 17:41:23

piezoelectric
Member
Registered: 2009-09-08
Posts: 32

Re: thunderbrand - a script to brand thunderbird without recompiling

What package is the command "convert" supposed to be in?

Offline

 

#7 2009-09-11 22:38:31

lyman
Member
From: China
Registered: 2008-01-13
Posts: 10
Website

Re: thunderbrand - a script to brand thunderbird without recompiling

piezoelectric wrote:

What package is the command "convert" supposed to be in?

$ pkgfile convert
extra/imagemagick


archlinux x86_64 on Fujitsu MG75X/V (T7250/4G/120G SSD/IntelX3100)

Offline

 

#8 2009-12-10 17:15:23

grassmonk
Member
From: Utah
Registered: 2007-11-14
Posts: 33

Re: thunderbrand - a script to brand thunderbird without recompiling

Here is an updated script for Thunderbird 3.0.  I didn't notice this thread earlier, so I based it off a combination of the firebrand script from http://bbs.archlinux.org/viewtopic.php?id=44320 and the thunderbrand script from the archlinux-fr repo.

Code:

#!/bin/bash
#
# thunderbrand3 - a script to brand Thunderbird 3.0 without recompilation
#
# Based on firebrand script from http://bbs.archlinux.org/viewtopic.php?id=44320
# and thunderbrand script from archlinux-fr repository
#
# Currently works for en-US locale.  Modifications are necessary for other locales.
#
# This script replaces and changes (a few) files in an existing Thunderbird
# installation. Run it after a Thunderbird installation or upgrade, and restart
# Thunderbird. The program icon may not be (visibly) replaced until your desktop
# environment is restarted.
#
# To revert to the original brand, simply reinstall Thunderbird.
#
# Dependencies: wget, unzip, zip
#

THUNDERBIRDDIR=""                           # Where Thunderbird's data files resides. Usually something like /usr/lib/thunderbird-3.0.
                                            # If empty, autodetection is attempted.
NEWICONSDIR=""                              # If empty, the script uses a temporary directory for the replacement icons.
                                            # If you want to avoid downloading the icons every time you rebrand Thunderbird,
                                            # point NEWICONSDIR to a suitable directory.
SOURCEBASE="http://mxr.mozilla.org/comm-1.9.1/source/other-licenses/branding/thunderbird" # The URL under which the branding directory resides.



echo "This script must be launched as root to work."



die () {
    EXITCODE="${1:-9}"
    MESSAGE="$2"

    echo -e "\n$MESSAGE"

    exit $EXITCODE
}



get_icon() {
    local ICON="$1"
    local SOURCEFILE="$2"

    echo -n " - $ICON"

    if [ -e "$NEWICONSDIR/$ICON" ] ; then
        if [ -f "$NEWICONSDIR/$ICON" ] ; then
            echo " is present."
            return 0
        else
            die 1 " is present but is not a file. Quitting."
        fi
    fi

    echo -n ": Downloading... "
    if wget -q -O - "${SOURCEBASE}${SOURCEFILE}" > "$NEWICONSDIR/$ICON" ; then
        echo "Done."
        return 0
    else
        die 1 "Failed."
    fi
}



for EXEC in wget unzip zip ; do
    if ! which $EXEC > /dev/null 2>&1 ; then
        die 1 "This script requires $EXEC to work."
    fi
done



if [ "x$THUNDERBIRDDIR" == "x" ] ; then
    THUNDERBIRDDIR=$(ls -1d /usr/lib/thunderbird-* | sort | tail -1)

    if [ "x$THUNDERBIRDDIR" == "x" ] ; then
        die 1 "Could not find the Thunderbird data directory."
    fi

    echo "Thunderbird data directory is ${THUNDERBIRDDIR}."
fi

if [ ! -d "$THUNDERBIRDDIR" ] ; then
    die 1 "$THUNDERBIRDDIR is not a directory."
fi

CHROMEDIR=$THUNDERBIRDDIR/chrome                # Simply the Thunderbird chrome directory.



TEMPDIR=$(mktemp -d -t thunderbrand-XXXXXXXX)

if [ $? -ne 0 ] ; then
    die 1 "Could not create temporary work directory."
fi

if [ "x$NEWICONSDIR" == "x" ] ; then
    NEWICONSDIR=$(mktemp -d -t firebrand-icon-XXXXXXXX)

    if [ $? -ne 0 ] ; then
        die 1 "Could not create temporary icon directory."
    fi
else
    [ -e "$NEWICONSDIR" ] || mkdir -p "$NEWICONSDIR" || die 1 "Could not create icon directory $NEWICONSDIR."
fi



echo -e "\033[1mChecking replacement icons\033[0m"
get_icon "about-credits.png"    "/content/about-credits.png?raw=1"
get_icon "about.png"            "/content/about.png?raw=1"
get_icon "icon48.png"           "/content/icon48.png?raw=1"
get_icon "icon64.png"           "/content/icon64.png?raw=1"
get_icon "default16.png"        "/mailicon16.png?raw=1"
get_icon "default22.png"        "/mailicon22.png?raw=1"
get_icon "default24.png"        "/mailicon24.png?raw=1"
get_icon "default32.png"        "/mailicon32.png?raw=1"
get_icon "default48.png"        "/mailicon48.png?raw=1"
get_icon "default256.png"       "/mailicon256.png?raw=1"



echo -e "\033[1mRE-BRANDING chrome/en-US.jar\033[0m"
echo -n " - Unzipping en-US.jar to ${TEMPDIR}... "
unzip -q -d "$TEMPDIR" "$CHROMEDIR/en-US.jar" locale/branding/brand.dtd locale/branding/brand.properties && echo "Done." || die 1 "Could not unzip branding files."

sed -r -i 's_(brandShortName=)[^"]+_\1Thunderbird_g' $TEMPDIR/locale/branding/brand.properties && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.properties" || die 1 "Could not edit ${TEMPDIR}/locale/branding/brand.properties"
sed -r -i 's_(brandFullName=)[^"]+_\1Mozilla Thunderbird_g' $TEMPDIR/locale/branding/brand.properties && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.properties" || die 1 "Could not edit ${TEMPDIR}/locale/branding/brand.properties"
sed -r -i 's_(vendorShortName=)[^"]+_\1Mozilla_g' $TEMPDIR/locale/branding/brand.properties && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.properties" || die 1 "Could not edit ${TEMPDIR}/locale/branding/brand.properties"
sed -r -i 's_(brandShortName[ \t]+)"[^"]+"_\1"Thunderbird"_g' $TEMPDIR/locale/branding/brand.dtd && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.dtd" || die 1 "Could not edit file ${TEMPDIR}/locale/branding/brand.dtd"
sed -r -i 's_(brandFullName[ \t]+)"[^"]+"_\1"Mozilla Thunderbird"_g' $TEMPDIR/locale/branding/brand.dtd && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.dtd" || die 1 "Could not edit file ${TEMPDIR}/locale/branding/brand.dtd"
sed -r -i 's_(vendorShortName[ \t]+)"[^"]+"_\1"Mozilla"_g' $TEMPDIR/locale/branding/brand.dtd && echo " - Successfully edited ${TEMPDIR}/locale/branding/brand.dtd" || die 1 "Could not edit file ${TEMPDIR}/locale/branding/brand.dtd"

echo " - Replacing branding files in en-US.jar"
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/en-US.jar" locale/branding/* )



echo -e "\033[1mRE-BRANDING chrome/messenger.jar\033[0m"
echo " - Replacing branded icons in messenger.jar"
mkdir -p "$TEMPDIR/content/branding"
cp "$NEWICONSDIR"/{about-credits.png,about.png,icon48.png,icon64.png} "$TEMPDIR/content/branding/"
( cd $TEMPDIR && zip -q -r "$CHROMEDIR/messenger.jar" content/branding/* )



echo -e "\033[1mRE-BRANDING defaults/pref/all-thunderbird.js\033[0m"
sed -r -i 's_^(pref\("general.useragent.extra.thunderbird", ")[^/]+(/.*"\);[ \t]*)$_\1Thunderbird\2_' $THUNDERBIRDDIR/defaults/pref/all-thunderbird.js && echo " - Successfully edited $THUNDERBIRDDIR/defaults/pref/all-thunderbird.js" || die 1 "Could not edit $THUNDERBIRDDIR/defaults/pref/all-thunderbird.js"



echo -e "\033[1mRE-BRANDING thunderbird\033[0m"
sed -i 's|Shredder|Thunderbird|g' $THUNDERBIRDDIR/thunderbird && echo " - Successfully edited $THUNDERBIRDDIR/thunderbird" || die 1 "Could not edit $THUNDERBIRDDIR/thunderbird"



echo -e "\033[1mReplacing icons...\033[0m"
cp "$NEWICONSDIR"/{default16.png,default22.png,default24.png,default32.png,default48.png,default256.png} $THUNDERBIRDDIR/chrome/icons/default/
cp "$NEWICONSDIR/icon64.png" /usr/share/pixmaps/thunderbird.png
chmod 644 /usr/share/pixmaps/thunderbird.png
chown root:root /usr/share/pixmaps/thunderbird.png

Offline

 

#9 2009-12-19 20:00:44

qpieus
Member
Registered: 2008-03-07
Posts: 16

Re: thunderbrand - a script to brand thunderbird without recompiling

grassmonk wrote:

Here is an updated script for Thunderbird 3.0.  I didn't notice this thread earlier, so I based it off a combination of the firebrand script from http://bbs.archlinux.org/viewtopic.php?id=44320 and the thunderbrand script from the archlinux-fr repo.

Thanks, worked great.

Offline

 

#10 2009-12-20 01:27:54

jithin1987
Member
From: Bangalore
Registered: 2009-09-11
Posts: 180

Re: thunderbrand - a script to brand thunderbird without recompiling

Nice. Works great.


Thanks
Jithin

Offline

 

#11 2010-01-18 12:59:29

ZeroCool
Member
From: Bad Münder Germany
Registered: 2009-08-18
Posts: 22

Re: thunderbrand - a script to brand thunderbird without recompiling

big Thanks smile

Offline

 

#12 2010-02-02 17:29:26

piezoelectric
Member
Registered: 2009-09-08
Posts: 32

Re: thunderbrand - a script to brand thunderbird without recompiling

Has anyone thought about just making a firebrand/thunderbrand package for the AUR? maybe a single package called mozbrander...?

Offline

 

Board footer

Powered by FluxBB