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,293

3 Answers3

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
  • 85,475
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,293
1

Here's a solution that I used to figure out how Chrome renders it context menu to configure it for use with picom or compton. This was hard because technically the menu is rendered by Chrome window and while the menu is open, the mouse is grabbed so I cannot use xprop directly.

In practice, I used xwininfo to get list of all X windows (including the ones that have no user visible or accessible parts) and then run xprop -id against every one of those.

Here's the bash one-liner which creates files called res1, res2, ..., res9 in the current working directory if you let in run for about 10–20 seconds:

for ((i=1; i<=9; i++)); do echo -n "res$i ..."; xwininfo -root -tree | sort -u | grep -oP '^\s*0x[0-9a-f]+\b' | xargs -rn1 xprop -id > res$i; echo " done"; sleep 2; done

It shows res1... while the snapshotting of the first state is in process (running xprop repeatedly for every single window takes some time) and then done is appended after the snapshot is complete. Then you have 2 seconds to change the state of the system (e.g. switch to another window, click a menu open, open a new app) and then another snapshot of the system state is taken. Try to make any changes between seeing "done" and the "res..." on next line.

Keep in mind when you did the change to the system you're interested in. For example, when I executed above, I let it collect current state while I'm still in terminal. When I saw done, I switched to Chrome window and waited until seeing another done (which was the line res2 in my case). Then I opened the menu I was interested in and waited with the open menu until seeing res3... done to know that I have full snapshot for that state. I then switched back to the terminal and pressed Ctrl+C to stop the data collecting (it would automatically stop after collecting 9 states).

Now I knew that the change I was interested in was between states res2 and res3 so I could run meld res2 res3 & to view the changes in graphical comparision UI.

Update: here's an even longer one-liner for those pesky windows that xprop shows nothing for. This one collects both xprop and xwininfo for all windows but it's pretty slow to run. It similarly creates files called res1, res2, ..., res9 in current working directory:

for ((i=1; i<=9; i++)); do echo -n "res$i ..."; echo > "res$i"; xwininfo -root -tree | sort -u | grep -oP '^\s*0x[0-9a-f]+\b' | while read id; do echo -n "."; printf "\n\nWindow id %s:\n\n" "$id" >> "res$i"; xprop -id "$id" >> "res$i"; xwininfo -id "$id" >> "res$i"; done; echo " done"; sleep 2; done

For an example, here's the command line I use to run picom without any config files:

picom --config /dev/null  --log-file /dev/null --shadow -o 0.50 -r 8 -l -8 -t -8  --corner-radius 4 --backend glx --glx-no-stencil --glx-no-rebind-pixmap --no-use-damage --xrender-sync-fence --vsync --shadow-exclude '_GTK_FRAME_EXTENTS@:c' --shadow-exclude "name ?= 'Thunderbird' && (window_type = 'utility' || window_type = 'popup_menu')" --rounded-corners-exclude "_NET_WM_WINDOW_TYPE:a = '_NET_WM_WINDOW_TYPE_DND'" --shadow-exclude "_NET_WM_STATE:a = '_NET_WM_STATE_ABOVE' && _NET_WM_WINDOW_TYPE:a = '_NET_WM_WINDOW_TYPE_MENU'" --shadow-exclude "WM_CLASS:s = 'xfwm4-wireframe'" --shadow-exclude '! class_g && ! class_i && ! _NET_WM_WINDOW_TYPE:a' --no-fading-openclose --unredir-if-possible --unredir-if-possible-delay 50 > /dev/null 2>&1 &