There already exists a program that does this for X windows (and possible SunView, but I never looked). Try getting ms from prep.ai.mit.edu in pub/gnu. The file name has a version number tacked on, but I think you will be able to find it. Cheers!greg