http://unix.stackexchange.com/questions/72131/detecting-x-session-in-a-bash-script-bashrc-etc/338862#338862