2

I need to see the X properties of the Gnome-Do popup window, in regard to this question that I asked earlier. The problem is that as soon as the Gnome-Do window loses focus it closes, so I can't change focus to the terminal to run xprop. The answer I keep seeing on the internet is:

sleep 5; xprop

Then open the Gnome-Do window and wait for xprop to start. It seems clever, but simply doesn't work:

$ sleep 5; xprop
xprop: error: Can't grab the mouse.

The same goes for xwininfo:

$ sleep 5; xwininfo 

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.
xwininfo: error: Can't grab the mouse.

I've also tried running xprop using the Mod+R shortcut in Awesome WM, but while the Gnome-Do window is open, the shortcut doesn't work. It just types an r into the search box.

I have no more ideas. How do I do this?

Hubro
  • 1,283
  • 6
  • 19
  • 34
  • that is a pitty. Will think about it and try tomorrow if no one has the solution by then. Will remove the answer for now. – Jacob Vlijm just now – Jacob Vlijm Jan 27 '15 at 22:24
  • I have to run, but do you have `wmctrl` on your system? we could run the script with the same trick to at least *identify* the window, then combine it with `xprop` to get the data. – Jacob Vlijm Jan 27 '15 at 22:35
  • @JacobVlijm: Nice, the `wmctrl` command solved it! Thanks :D – Hubro Jan 27 '15 at 22:51

2 Answers2

2

If you run the script below, it records for 10 seconds (or any other time you set) the output of the xprop command on the frontmost window (running the xprop -root command). Subsequently, it writes the output, after the time has elapsed, to a file: outfile.txt
If you make sure to keep the Gnome-Do window active until the script has finished, you can be sure the last record is corresponding to the Gnome-Do window.

To use it

  • Simply copy the script below into an empty file, set, in the head section, the desired path to the output file (outfile =, use an absolute path). Save it as record_xprop.py

  • Start the script by the command:

      python3 /path/to/record_xprop.py
    
  • Call your Gnome-Do window (or any other application you need data from).

  • After the time has elapsed, your outputfile will show five times the output of the xprop -root command, separated by a dotted line.

Note

If you need more time, just change the "5" in the line:

 while t < 5:

into any other value you need

The script

#!/usr/bin/env python3
import subprocess
import time

outfile = "/home/jacob/Bureaublad/outfile.txt"
data = []; t = 0
while t < 5:
    data.append(subprocess.check_output(["/bin/bash", "-c", "xprop -root"]).decode("utf-8"))
    time.sleep(2)
    t = t + 1
with open(outfile, "wt") as out:
    for rec in data:
        out.write(rec+"\n"+"-"*20+"\n\n")

Edit

If this does not work for some reason (appearantly the window is not frontmost, as recognized by xprop), we could do the same trick with the wmctrl -l command (replace xprop -root by wmctrl -l in the script), to identify the window by its name first.
Once that is done, we can subsequently run again xprop, with the -name option, to get the needed info: xprop -name <windowname>

For both commands, you can run either the sleep command, or, if you need more time, run the script again.

Jacob Vlijm
  • 82,471
  • 12
  • 195
  • 299
  • Nice thought, but it doesn't work. Even though the Gnome-Do window is on top and focused, none of the output from your script is for the Gnome-Do window. I've retried many times, and I've tried to explicitly focus the Gnome-Do window by clicking it and typing into it while your script ran. – Hubro Jan 27 '15 at 22:21
  • I'll keep my answer, as it has more detail and could be useful to someone, but you deserve the credit – Hubro Jan 28 '15 at 05:21
2

Jacob got it in the comments!

Using the sleep 1; wmctrl -l command, then opening Gnome-Do, I got this output:

0x00e000b9  0 bonus-debian Do

Which shows the name of the Gnome-Do window. Then I could use the name to identify the window for xprop:

sleep 1; xprop -name "Do"

Which gave me the output I was after:

$ sleep 1; xprop -name "Do"
WM_STATE(WM_STATE):
        window state: Withdrawn
        icon window: 0x0
GDK_TIMESTAMP_PROP(GDK_TIMESTAMP_PROP) = 0x61
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 14680093
_XEMBED_INFO(_XEMBED_INFO) = 0x1, 0x1
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0xe00004
WM_CLIENT_LEADER(WINDOW): window id # 0xe00001
_NET_WM_PID(CARDINAL) = 6708
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "bonus-debian"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
        program specified minimum size: 19 by 19
        window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Do", "Do"
WM_ICON_NAME(STRING) = "Do"
_NET_WM_ICON_NAME(UTF8_STRING) = "Do"
WM_NAME(STRING) = "Do"
_NET_WM_NAME(UTF8_STRING) = "Do"
Hubro
  • 1,283
  • 6
  • 19
  • 34