#!/bin/sh
### NOTE: Here you (can) choose whether you are trying to 'fix' google-chrome(-beta/-dev), chromium-browser or iron
## Google-chrome(-beta/-dev) users select this one (default):
_destdir=/opt/google-chrome && _exec=${_destdir}/google-chrome
## Chromium-browser users (uncomment this & comment the Google-chrome one (in case you use chromium-browser)):
#_destdir=/opt/chromium-browser && _exec=/usr/bin/chromium-browser
## Iron users (same thing):
# _destdir=/opt/iron && _exec=/usr/bin/iron
# For the wget (download) section (to get the correct file)
_arch='i386'
[[ `uname -m` = "x86_64" ]] && _arch='amd64'
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# If the .cache file was not found (meaning this was the first time doing this), we do all the other stuff too
if [[ ! -f ${_destdir}/loaders.cache ]]; then
# Create our custom dir for doing this (and cd there)
mkdir ~/chrome-libjpeg6
cd ~/chrome-libjpeg6
# Fetch the .deb and extract the archives
wget http://mirrors.easynews.com/linux/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-0_2.18.3-1_${_arch}.deb
ar -xv libgtk2.0-0_2.18.3-1_${_arch}.deb
tar -xvf data.tar.gz
# Cd to where sh*t is going down (the install dir)
cd ${_destdir}
# Move the jpeg-loader file (t)here
mv ~/chrome-libjpeg6/usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-jpeg.so .
# Create the .cache file and modify the jpeg-loader pointer line there (this changes all the other pointer lines too but no matter)
gdk-pixbuf-query-loaders > loaders.cache
sed -i "s|/usr/lib/gdk-pixbuf-2.0/2.10.0/loaders|${_destdir}|" loaders.cache
# Done. We can now remove our custom dir
rm -r ~/chrome-libjpeg6
fi
# Check whether this script was already run (or done manually). If not, put a line (and a comment) to our main
# chrome/chromium/iron script to read the generated .cache file. With all these browsers this needs to be done
# differently (hence the whole "if - then" query section)
if [[ `cat ${_exec} | grep GDK` = "" ]]; then
if [[ "${_destdir}" = "/opt/google-chrome" ]]; then
sed -i '/^exec/i\# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache\n' ${_exec}
elif [[ "${_destdir}" = "/opt/chromium-browser" ]]; then
sed -i '/^done/a\\n# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache' ${_exec}
elif [[ "${_destdir}" = "/opt/iron" ]]; then
echo -e "\n# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache" >> ${_exec}
fi
echo; echo All done! # Say "done" here to make sure that people who had already done this before (and just updated chrome/
else # chromium/iron) don't wonder the script completing so fast (because there was only this sed'ing to do)
echo Nothing to be done.
fi