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