Oh, ubuntu...
Usually most distributions will let you start Xorg yourself rather than let a login manager do it such as GDM or KDM. If you run startx from the commandline, it will read the ~/.xinitrc and load any window managers or other stuff you put there. But since you have Ubuntu....
To run a script prior to GDM/KDM startup, you could either
- Write your own Upstart script to run prior to GDM; or
- Modify your system GDM script to run a custom external script (eg, your /etc/init.d/whereami script) as one of its initial tasks.
- Run your Xorg-application before GDM/KDM runs, put the script in /etc/init.d/SXYYourScript where XY is lower number than the GDM one.
Also check /etc/gdm/Init/Default maybe is what you want.
I suggest you go with 3 since its more simpler.
But why would you run any Xorg app before the login manager?