 
     ipc.on 'updatebadge', (ev, value) ->
         app.dock.setBadge(value) if app.dock
+        if value > 0
+            tray.setImage path.join __dirname, 'icons', 'icon-unread.png'
+        else
+            tray.setImage path.join __dirname, 'icons', 'icon.png'
 
     ipc.on 'searchentities', (ev, query, max_results) ->
         promise = client.searchentities query, max_results

    # For OSX only hides the window if we're not force closing.
    # Prevent close, if minimizetotray is enabled.
    mainWindow.on 'close', (ev) ->
        hideToTray = hasTray and !readyToClose and nconf.get 'minimizetotray'
        darwinHideOnly = process.platform == 'darwin' and not mainWindow?.forceClose

        if hideToTray or darwinHideOnly


mainWindow = null
tray = null

# No more minimizing to tray, just close it
readyToClose = false
