Get xwininfo to list data of ALL gtkdialog GUIs? [ Solved ]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Get xwininfo to list data of ALL gtkdialog GUIs? [ Solved ]

#1 Post by sunburnt »

If I need xwininfo to ID a window by it`s title, the names can be very long ( Geany`s ).
This makes passing the window`s title as an argument almost impossible.
The entire title`s needed to get any info. With a list of all GUIs a search could be done.

I came close with: " xwininfo -root -children " , it does list the gtkdialog windows.
But no title, just the wrong window id for gtkdialog and maybe it`s export variable.
Most of them don`t list gtkdialog`s export variable, oddly Driveman`s is listed.

The first gtkdialog window run gets the id: 0x1000001, the rest get a letter mod.: 0x1e00001
Using -name gets window info, but with the wrong -id the geometry is wrong ( Great...).
Worse yet is that if the window is borderless ( no title ) then there`s no way to get it`s info!

Is there a way to get the GUI`s geometry from the Xwindow id ? Or any other way possible...
Last edited by sunburnt on Fri 23 Apr 2010, 06:37, edited 2 times in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

### Update: Eureka..! I think I have it! the real gtkdialog window`s last number is always: 3
So this gives a list of the correct id numbers for the gtkdialog GUI`s listed by xwininfo:

Code: Select all

xwinIDs=`xwininfo -root -children |grep gtkdialog3 |awk '{print $1}' |sed 's/1$/3/'`
So now can get a complete set of geometry for ALL gtkdialog windows.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Here`s a script to get ALL the data for ALL the gtkdialog GUI`s running:

Code: Select all

#!/bin/sh
######	gtkinfo : Get data on gtkdialog GUI`s

gtkIDs=`xwininfo -root -children |grep gtkdialog3 |awk '{print $1}' |sed 's/1$/3/'`
gtkINFO=`echo "$gtkIDs" |while read ID
do
	G=($(xwininfo -id $ID |sed '1,9!d'))
	T=`echo ${G[4]} |sed 's/"//g'`
	((X=G[8]-G[16], Y=G[12]-G[20], W=G[22], H=G[24]))
	((X<1)) && ((X=0)); ((Y<1)) && ((Y=0))
	echo -e "${T}_TITLE=$T\\n${T}_ID=$ID\\n${T}_X=$X\\n${T}_Y=$Y\\n${T}_W=$W\\n${T}_H=$H\\n"
done` ; eval "$gtkINFO"
Data for all running gtkdialog GUI`s output to " /tmp/gtkinfo.tmp " is: Title, ID, X, Y, W, H
It adds the prefix of the window`s title to the variable`s name: $GUI_TITLE, $GUI_X, etc.
This uniquely identifies each gtkdialog GUI`s variables in the file to keep them separate.
This should be in a library!
Last edited by sunburnt on Sun 25 Apr 2010, 00:58, edited 2 times in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

Changed it so you run it "sourced" like: ". gtkinfo". So now no file needs to be made.
And then the list of gtkdialog info is in the variable: $gtkINFO

Post Reply