User:NoobCp/Start X at Boot

From ArchWiki

From: https://wiki.archlinux.org/index.php?title=Start_X_at_Boot&oldid=187286

Or with a prompt:

~/.bash_profile
if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  while true; do
    read -p 'Do you want to start X? (y/n): '
    case $REPLY in
      [Yy]) exec xinit -- /usr/bin/X -nolisten tcp vt7 ;;
      [Nn]) break ;;
      *) printf '%s\n' 'Please answer y or n.' ;;
    esac
  done
fi

The user will be logged out when X is killed. In order to avoid this, remove the exec part from the script.