Ubuntu – How to start Thunderbird minimized to Unity system tray on start-up

autostartemailsystem-traythunderbirdunity

There is actually a question that covers this same topic, but none of the answers worked for me, at least not completely.

The accepted answer is just a link to this forum thread, and based on one of its suggestions (that didn't work for me initially), I managed to put together this:

#!/bin/bash

thunderbird &
while [[ $(wmctrl -l | grep "Mozilla Thunderbird") == "" ]]; do sleep 0.1; done
xdotool windowactivate --sync `xdotool search --name "Mozilla Thunderbird"`
sleep 0.1       # prevents flakiness
xdotool key alt+F4
exit 0

Which, together with the addon MinimizeToTray revived to cause it to minimize to tray instead of closing, works. I have it set to run automatically, and it closes the window, but the mail notification applet in the system tray still turns blue when I have an email.

The only problem is that, when logging in, you will still see the window "flash" as it opens and closes, and I find this annoying (though I'm willing to put up with it if I have to).

There is another, similar add-on called FireTray which has the advantage that you can set Thunderbird to open automatically minimized to the system tray (and this works), negating the need for a script (all you would need to do is set up the extension, then add thunderbird to the startup programs).

However, for reasons I don't really understand, enabling FireTray messes up the icons for Firefox and Thunderbird. They become really blurry, and I can't figure out how to fix it. I googled to see if anyone had this problem, but I couldn't find anything.

Basically, my question is just if anyone has any ideas on either how to fix either of these problems. Either prevent FireTray from messing up the icons, or close Thunderbird with MinimizeToTray revived without the window flashing.

Edit: After experimenting with FireTray more, I realized that it does the same window flashing thing, which makes me think it's unlikely to prevent or hide it.

Best Answer

You can try MailNag:

sudo add-apt-repository -y ppa:pulb/mailnag
sudo apt -y update
sudo apt -y install mailnag-unity-plugin mailnag

Then, run mailnag-config and set up your Accounts (to my knowledge, there's no automated way to import all Thunderbird email accounts), and then make sure the Unity plugin is enabled.

You don't need any add-ons for Thunderbird; in fact, I would actually advise removing the default Messaging Menu and Unity Launcher Integration add-on, because you can open the default email client from the Unity panel via mailnag, and so there's little point for it.

mailnag should automatically set itself as a startup script, so you should get both notifications in the panel (read: the mail icon turns blue) and the overlay style notifications like when you connect/disconnect from a network.

This obviously doesn't actually 'start Thunderbird minimized to system tray on start-up', but it does solve my underlying problem of 'automatically get email notifications in Unity panel on start-up', and the only difference between it and my intended behavior is that thunderbird isn't running. I suppose this is probably why I couldn't find anything about it; now that I know to search for mailnag and found a couple relevant questions.

Related Question