3

I wanted Thunderbird to stay in the Background to notify me of incoming mails.

After a bit of searching, I found this post.
How to keep Thunderbird and Pidgin running on background?

The solution is to install an addon so that when we close Thunderbird it just stays in the background.

Now, to have thunderbird running at Start up we can just add it to Startup Applications.

But, when I open my system, Thunderbird also gets opened and I have to manually press the close button everytime to make Thunderbird go into the background.

The solution given in the above post for this problem is to select Minimize on start. But doing so affects the way in which Thunderbird works when invoked from the Messaging menu. So I deselected this option.

But, if there is a way to emulate pressing the Close button from a script, I can just add that script to Startup Applications

So is there a way to achieve this?

Note : If there is a simpler way to solve my original problem of keeping Thunderbird in background please post that also.

Many thanks.

Hashken
  • 6,282
  • According to the link you gave, the extension "Minimize On Start and Close" provides the option to minimise on open. Have you tried that? Regarding a simpler way, I just put Thunderbird on a different workspace! – Paddy Landau Dec 12 '12 at 16:28
  • Forgot to add this. If we select Minimize on start then while pressing the mail entry in the Messaging menu, Thunderbird does not open up properly. I need to once again go and press the Thunderbird icon. So, I removed Minimize on start option. – Hashken Dec 12 '12 at 16:33
  • Edited the question,the explain the change. – Hashken Dec 12 '12 at 16:38

1 Answers1

2

In the probable absence of a Thunderbird command-line option that you could use to start it minimized or in the background, your best option is probably to use something like xdotool, which is in the repositories. (See my later note on the minimize to tray addon).

This is the command you need to minimise the instance of Thunderbird; xdotool searches for the Thunderbird window on the window stack and then minimizes it

xdotool search --class thunderbird windowminimize %@

Maximise Thunderbird and then try it in the terminal; it seems to be the command you are looking for. Often when used in scripts the --sync argument is added, as noted in the man page:

After requesting the window minimize, wait until the window is actually minimized. This is useful for scripts that depend on actions being completed before moving on.

You may also have to delay the command a bit until Thunderbird has actually started up, and there is a sleep command built into xdotool, so you could use

xdotool sleep 6 search --class thunderbird windowminimize %@

and set the sleep interval at whatever value you needed.

This minimises Thunderbird, but not to the background like when you use the minimize to tray addon, as you set up that addon so that pressing exit sends Thunderbird to the tray. Assuming that addon is installed, it may be possible to use xdotool to emulate the mouse-click of the x in Thunderbird's window and so background it. However, using windowkill instead of windowminimize with Thunderbird (when the tray addon is installed) closes the entire application.


After discussion it was said that the windowunmap option was the one necessary to actually hide the window; this is much easier than trying to emulate a click on the thunderbird window.

xdotool sleep 6 search --class thunderbird windowunmap %@
  • +1, This is such an awesome tool. Hopefully I should be able to find a way to use this tool to emulate a close click. Will try it out and get back – Hashken Dec 12 '12 at 16:58
  • @Karthik Yes, it is a great tool- I'll see if I can do it for you as well- it should be possible. –  Dec 12 '12 at 17:01
  • The windowunmap option did the trick. The command will be like xdotool sleep 6 search --class thunderbird windowunmap %@ – Hashken Dec 12 '12 at 17:09
  • Can you please update your answer with the info in my previous comment. – Hashken Dec 12 '12 at 17:18
  • @Karthik Yes, I have done the edit, and I'll also see if it's possible to do it it by simulating a mouse-click. Thanks. –  Dec 12 '12 at 17:43
  • From what I have seen so far mouse clicks take only x, y coordinates. This means that I have to find the position of the Close button. Anyways, I will read up more and see if this is possible. – Hashken Dec 13 '12 at 01:42
  • +1, Great job @Milk and @Karthik!! Can I update my answer in the How to keep Thunderbird and Pidgin running on background? question with your solution? Just to have a complete answer to that question! (if you matter about askubuntu points I'll point back to this question with a link!!) – naskoos Dec 31 '12 at 13:52
  • @naskoos Thanks. Yes, that's fine- just link it for reference. –  Dec 31 '12 at 13:58