Google Chrome – Replace Low Resolution Notification Icon

google-chromeiconsnotification

Google Chrome was recently upgraded to version 35.0.1916.114 on my Ubuntu 14.04 installation.

Since then the notification icon has begun to show up on the system tray. However it seems it's using a low resolution icon – it looks distorted:

enter image description here

How can I fix/replace it?

Best Answer

Edit: see below for update on replacing notification icon

If you're chrome binaries are installed in the typical location, you'll find them in /opt/google/chrome. In that folder you should find the file chrome_100_percent.pak which contains the notification icon. Here's the steps I used to extract it, using information from this stack overflow question:

  1. Checkout the code to the grit-i18n project with

    svn checkout http://grit-i18n.googlecode.com/svn/trunk/ grit-i18n-read-only

  2. This will give you a folder in your CWD called grit-i18n-read-only. CD into this folder

    cd grit-i18n-read-only

  3. Copy the data_pack python module to this folder

    cp grit/format/data_pack.py .

  4. Edit data_pack.py in your preferred editor. After the initial imports, add the following line:

    sys.path.append(os.getcwd())

  5. Towards the end of the file in the main function, remove the line

    print '%s: %s' % (resource_id, text)

    (the Stack Overflow answer states this occurs at line 160, in my experience the current version has it at line 201)

  6. In its place, insert the following lines indented appropriately (3 times):

    file = open(str(resource_id), "wb")

    file.write(text)

  7. Run the data_pack.py utility on the chrome pak file (I copied it to the grit-i18n-read-only folder first):

    ./data_pack.py ../chrome_100_percent.pak

This will result in a lot of new files in the current directory, all named as numbers with no extension. Your file browser (e.g. nautilus) should be able to determine the file types and show image thumbnails. I found the notification icons named as 6866 & 6867.


Edit

While there are some simpler answers below, I managed to hack together some code to re-package the resources which you could attempt after editing the icons. This would produce a new .pak file, which I haven't attempted to use myself, so I can't say for certain this would successfully result in new notification icons.

In the main function in data_pack.py, I commented out all the code in the else block and added the following lines:

# Read in the modified icon resource files
file = open('6864', 'r')
icon1 = file.read()
file.close()
file = open('6865', 'r')
icon2 = file.read()
file.close()
file = open('6866', 'r')
icon3 = file.read()
file.close()
file = open('6867', 'r')
icon4 = file.read()
file.close()

# Write resource pak of only notification icons
iconData = {6864: icon1, 6865: icon2, 6866: icon3, 6867: icon4}
WriteDataPack(iconData, 'tmp.pak', BINARY)

# Create copy of original pak without notification icons
dataPack = ReadDataPack('chrome_100_percent.pak')
# List of icon resources to remove
toRemove = set([6864,6865,6866,6867])
whiteList = set(dataPack.resources.keys()).difference(toRemove)
whiteListFile = open('whitelist.txt', 'w')
for i in whiteList:
  whiteListFile.write(str(i)+'\n')
whiteListFile.close()
newDataPack = RePack('tmp2.pak', ['chrome_100_percent.pak'], 'whitelist.txt')

# Merge the two paks together
combinedPack = RePack('chrome_100_percent_new.pak', ['tmp2.pak', 'tmp.pak'], None)

Then, just run ./data_pack.py. This assumes chrome_100_percent.pak is in the current directory, and should give you a new chrome_100_percent_new.pak file which you could attempt copying over /opt/google/chrome/chrome_100_percent.pak.

I believe some additional icons in the resource pak related to the notification icon have been identified; editing the above to include those should be pretty straightforward.


Final Edit

Now that I'm back home and had the chance to work on this some more, I managed to successfully replace chrome's notification icon. As @Glutanimate noted, you're stuck with 16x16 resolution, so I'm not sure how much improvement you can actually achieve, but I suppose that's subjective.

I simply opened the aforementioned icons (6864 - 6867) in GIMP, which detected them as Grayscale PNGs. I pasted a new icon into the same file in GIMP, thus attempting to keep the same image properties (e.g. grayscale). I then exported these as PNGs, unchecking ALL of the options that GIMP offers but maintaining a compression level of 9. The resulting files had .png extensions, so I removed those and replaced the originals. I then re-ran data_pack.py, having already made the modifications detailed above.

I kept a backup copy of the original pak with mv /opt/google/chrome/chrome_100_percent.pak /opt/google/chrome/chrome_100_percent.bak and moved my modified .pak file in its place. I would make sure chrome is closed when doing this, and double-check that there are no chrome processes running, and I believe chrome has a new setting to allow background processes even when the browser is closed by default now.

Lo and behold, my notification icons in Unity reflect my changes.

Finally-Final Edit: OK, I lied - I attempted a 32x32 PNG and it seems to have worked just fine. So, there you go. Here some result screenshots.

  • Original Icon: You'll probably recognize the default 'no unread notifications' icon in my panel here between my dropbox and weather icons:

Original Icon

  • New Icon: My 32x32px modified version in the same location:

New Icon

(Source: Batch icons from Adam Whitcroft)