2

I'm trying to write a shell script that recognizes if Thunderbird window is displayed and if so it disposes it to the messages tray.

I'd like to use it in this answer of "How to keep Thunderbird and Pidgin running on background?" question.

So far I'm using the "xdotool" to check if Thunderbird is displayed and simulate close on it as suggested in "How to emulate pressing the Close button from a script?".

    #!bin/bash
    thunderbird &
    TB=$(xdotool search --class thunderbird)
    while [ -z "$TB" ]; do
        sleep 2
        TB=$(xdotool search --class thunderbird)
    done
    xdotool search --class thunderbird windowunmap %@


But xdotool search --class thunderbird returns result by the time Thunderbird is launched, before is actually displayed, so xdotool search --class thunderbird windowunmap %@ waits for ever doing nothing.

To bypass this limitation a sleep xx is added in the actual command, but the sleep time needed, defers from system to system.

I've also used "xwininfo" to check if Thunderbird is displayed but it behaves the same as "xdotool", so I had to add sleep xx here too.

    #!bin/bash
    thunderbird &
    t="Thunderbird"
    stop=0

    xwininfo -name $t > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        stop=1
    fi

    while [ $stop -eq 0 ]; do
        xwininfo -name $t > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            stop=1
        fi
    done
    sleep 2
    xdotool search --class thunderbird windowunmap %@

Is there any other way to check for "really" displayed windows?

4
  • What is the reason for not just killing the thunderbird process gracefully using kill?
    – gertvdijk
    Jan 1, 2013 at 17:15
  • I want it to be minimized on the tray (message indicator) so that it can check for emails (running on the background)... Currently I'm using a Thunderbird add-on (MinimizedToTray) which does exactly this when you close it pressing the close button... I'm also using "xdotool" to emulate this click from a script.. kill is not an option I've tried it!
    – naskoos
    Jan 2, 2013 at 1:55
  • In that case, you should rephrase your question imho. You're stating you'd like a script to close Thunderbird. Now you appear you want to minimize windows of the running instance.
    – gertvdijk
    Jan 2, 2013 at 2:41
  • Maybe you are right I'll rephrase it, but my question is not how to close or how to simulate close or how to minimize the window, I've found that part (using "xdotool")... The actual question is on the title and on the last sentence! Thank you for your interest!!
    – naskoos
    Jan 2, 2013 at 9:04

1 Answer 1

0

Try this:

wmctrl -l | grep -i thunderbird

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .