You can get all the info for the current active window by using this command:
xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
or
xwininfo -id $(xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+)
Just parse the output for the co-ordinates you need. Here are some useful commands when interacting with windows:
- xwininfo will give you the relative and absolute geometry.
- xprop will tell you a lot of info, including if the window is active, but not it's geometry
- xdpyinfo will get you the id of the active window too, but no extra info.
- wmctrl will get you a list of information about windows, and allow you select the active window for modification, but not information.
For example to change the title of the active window to "New Name":
wmctrl -r :ACTIVE: -N "New Name"
Or to change the position of the active window:
wmctrl -r :ACTIVE: -e 0,20,20,200,400
Consider wmctrl if you need to just change something simple, like the window's geometry. Consider using the other scripts mentioned above only if you want to do other more complex things.