dump_selections.sh: use a more robust way to get the window name
[experiments/x-selection-debug.git] / dump_selections.sh
1 #!/bin/sh
2
3 [ -x ./xowner ] || make
4
5 get_owner() {
6   echo -n "$1"
7   OWNER=$(./xowner $1)
8   if [ $OWNER != "0x0" ];
9   then
10     xwininfo -id $OWNER > /dev/null 2>&1;
11     if [ $? -eq 0 ];
12     then
13       OWNER_NAME=$(xprop -id $OWNER | grep "^WM_NAME" | cut -d ' ' -f 3-)
14       if [ -z "$OWNER_NAME" ];
15       then
16         OWNER_NAME="$OWNER"
17       fi
18       echo -n " owned by $OWNER_NAME"
19     fi
20   fi
21
22   echo ":"
23 }
24
25
26 get_owner "PRIMARY"
27 xclip -out -selection primary 2> /dev/null
28 echo
29 echo
30
31 get_owner "SECONDARY"
32 xclip -out -selection secondary 2> /dev/null
33 echo
34 echo
35
36 get_owner "CLIPBOARD"
37 xclip -out -selection clipboard 2> /dev/null
38 echo
39 echo
40
41 get_owner "CUT_BUFFER0"
42 xcb -p 0
43 echo
44 echo