Ubuntu – How to keep Thunderbird and Pidgin running on background


Is there any way to keep messaging services (IM – Pidgin, mail client – Thunderbird) running "on background"? I want to have them waiting for incoming messages but they disturb me when switching between applications using alt-tab. Anyway, I access those programs by clicking on the envelope indicatior in the toolbar so I don't need to see them in the list of running apps. My desire is the behavior just like with Banshee or Empathy.

I don't want the solutions like AllTray since the applications already have their "tray" in the envelope applet.

EDIT: I have realized Pigin behaves like this. I don't know if it did before but now it's okay. So just Thunderbird now…

Best Answer

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:
        #wait for internet connection up to 15 seconds
        CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
        while [ "$CONNECTED" = "down" ] && [ $STOPWATCH -lt 15 ]; do
            sleep 1;
            CONNECTED=$(ping -w5 -c1 $host > /dev/null 2>&1 && echo "up" || echo "down")
            let STOPWATCH++
        #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)
        #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!