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?

naskoos
  • 379

2 Answers2

0

I use devilspie2 a great software to control my windows. Attention to the number 2 because there is a different version. I think this is an upgrade to the other.

It has a --debug and a default.lua script that lists all current windows and applications. If you are good at text processing you can match the window title to figure out if it is displayed (this title may change when it is visible). You can also study devilspie2 documentation for other various and powerful options.

Devilspie2 online Manual

A sample of the output running:

 $ devilspie2 ~/.config/devilspie2/default.lua --debug

Application: Thunderbird Window: Pastas Locais - Mozilla Thunderbird Class: thunderbird-esr Application: Thunderbird Window: Pastas Locais - Mozilla Thunderbird Application: Thunderbird Window: Pastas Locais - Mozilla Thunderbird Application: xfdesktop Window: Desktop Class: Xfdesktop Application: xfdesktop Window: Desktop Application: xfdesktop Window: Desktop Application: xfce4-panel Window: xfce4-panel Class: Xfce4-panel

0

Try this:

wmctrl -l | grep -i thunderbird
Adobe
  • 3,971