follw this link. it will help you.
http://www.thefourtheye.in/2013/04/ubuntu-screen-custom-resolution.html


when your computer backs to the previous resolution

register script of terminal...