When you login, your display gets attached to the ssh login environment (its a totally different environment.) use the command: export DISPLAY=0.0; && write ...
fill the dots, with your own command. Regards, Chhatoi Pritam Baral -- LUG@IITD - http://lug-iitd.org/Footer
