I don't know what a glut script is, I looked up glutGetWindow, and it seems to be an OpenGL function, but I don't know OpenGL (I'm not even that good with C yet), and I wouldn't know how to integrate that anyway. I saw a similar function in GTK, but again, the problem of integration.
The $WINDOWID variable seems to only exist in an xterm.
Damn, I thought this would have a simple "here, type this:" solution
Maybe I should have posted in the programming forum.