From: Antonio Ospite Date: Mon, 19 Jun 2017 14:28:59 +0000 (+0200) Subject: dump_selections.sh: print more details about the owner X-Git-Url: https://git.ao2.it/experiments/x-selection-debug.git/commitdiff_plain/refs/heads/master dump_selections.sh: print more details about the owner Always print the ID, and optionally the window name if there is one. Also if the window has no name try to get the parent id and name. --- diff --git a/dump_selections.sh b/dump_selections.sh index 9954a46..fcfd219 100755 --- a/dump_selections.sh +++ b/dump_selections.sh @@ -4,18 +4,31 @@ get_owner() { echo -n "$1" - OWNER=$(./xowner $1) - if [ $OWNER != "0x0" ]; + OWNER_ID=$(./xowner $1) + if [ $OWNER_ID != "0x0" ]; then - xwininfo -id $OWNER > /dev/null 2>&1; + OWNER="$OWNER_ID" + xwininfo -id $OWNER_ID > /dev/null 2>&1; if [ $? -eq 0 ]; then - OWNER_NAME=$(xprop -id $OWNER | grep "^WM_NAME" | cut -d ' ' -f 3-) - if [ -z "$OWNER_NAME" ]; + OWNER_NAME=$(xprop -id $OWNER_ID | grep "^WM_NAME" | cut -d ' ' -f 3-) + if [ -n "$OWNER_NAME" ]; then - OWNER_NAME="$OWNER" + OWNER="$OWNER $OWNER_NAME" + else + PARENT_ID=$(xwininfo -children -id $OWNER_ID | sed -n -e '/Parent window id:/s/.*window id: \([^ ]*\) .*$/\1/p') + if [ -n "$PARENT_ID" ]; + then + OWNER="$OWNER children of $PARENT_ID" + + PARENT_NAME=$(xprop -id $PARENT_ID | grep "^WM_NAME" | cut -d ' ' -f 3-) + if [ -n "$PARENT_NAME" ]; + then + OWNER="$OWNER $PARENT_NAME" + fi + fi fi - echo -n " owned by $OWNER_NAME" + echo -n " owned by $OWNER" fi fi