How to keep Thunderbird and Pidgin running on background?

EDIT 3: Thanks to @Mik and @Karthik How to emulate pressing the Close button from a script? we now have the best solution so far!!

You will need to install a Thunderbird extension:

  • MinimizedToTray revived (MinTrayR) 1.1.2
    • To make Thunderbird minimize on messenger indicator on close and minimize go to addon's "Preferences" and check "Instead of closing and when minimizing"

You also need to install "xdotool" to properly run the script below:

  • sudo apt-get install xdotool

To make Thunderbird start on system login and immediately minimize create the script below:

  1. Create an "Empty Document" in your Documents directory, name it "thunderbird_start.sh".
  2. Copy in it the following lines:
        #!bin/bash
    
        #wait for internet connection up to 15 seconds
        host=google.com
        CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
        STOPWATCH=0
        while [ "$CONNECTED" = "down" ] && [ $STOPWATCH -lt 15 ]; do
            sleep 1;
            CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
            let STOPWATCH++
        done
    
        #run Thunderbird
        thunderbird &
    
        #Search for Thunderbird window
        TB=$(xdotool search --class thunderbird)
        while [ -z "$TB" ]; do
            sleep 10 #Adjust this to your system needs
            TB=$(xdotool search --class thunderbird)
        done
    
        #dispose Thunderbird window
        xdotool search --class thunderbird windowunmap %@
    
    *I'm not very experienced in shell scripting so if there is any better implementation please let me know!
  3. Open "Startup Applications" and "Add" a new startup program.
  4. In the name field, give a name of your choice
  5. In the command field add the following line:
        bash /home/your-name/Documents/thunderbird_start.sh
    
    *maybe you could also use "~/" to get your home directory, but I'm not sure if is gonna work, you can try it: sh ~/Documents/thunderbird_start.sh

EDIT: MinimizedToTray officially does not support Unity so It breaks the global menu bar after restoring thunderbird. A work around is to disable global menu extension, till a fix release, or use HUD (ubuntu 12.04) to access thunberbird's options.

EDIT 2: I can confirm Karthik's comment, "MinimizedToTray revived 1.1.2" no more breaks Unity's global menu bar! Great thanks to Nils Maier...

EDIT 4: I've changed a bit the script code. I've added some lines to check for Internet connection so that sleep 10 is not needed any more...
ATTENTION in the 5th step sh was replaced with bash

EDIT 5: There is still a sleep 10 command in the script. You should adjust the sleep time according to your system's speed. For example in my laptop I have an SSD, so Thunderbird opens fast, sleep 2 works perfect. In my desktop PC I had to add 10 seconds of sleep to make it work properly... I have already issued an other question to overcome this limitation!


There is a very simple solution for that: You can configure Compiz to skip the taskbar and the pager for specified Applications. To do so with Thunderbird you have to perform following steps:

  1. Go to Softwarecenter and install CompizConfig or use following command:

    sudo apt-get install compizconfig-settings-manager

  2. Open CompizConfig-Setting-manager using the Dash or performing this command:

    ccsm

  3. Click on the left sidebar on »Windowmanager« CompizConfig-Setting-Manager

  4. Now you can specify windows you don't like appearing in taskbar and the pager: For Thunderbird you type in the filed »Skip Taskbar« and »Skip Pager« the following:

    class=Thunderbird Typing the same in the filed »not closable« you should have exactly the behaviour you want.

Skip pager and taskbar for Thunderbird