Skip to content

Instantly share code, notes, and snippets.

@dennyhalim
Created August 12, 2009 21:44
Show Gist options
  • Save dennyhalim/166797 to your computer and use it in GitHub Desktop.
Save dennyhalim/166797 to your computer and use it in GitHub Desktop.
#!/bin/bash
# http://it.dennyhalim.com/2008/10/linux-automatic-login-startx-and.html
# paste into your ~/.bashrc and it just works.
# it will startx / startxfce when you login at tty1
# it can also logout/shutdown after you close x.
file=/tmp/.X0-lock
#check if x is running
if [[ -e $file ]]
then
echo "Ctrl+Alt+F7 to switch to XWindow"
#only run X if login at tty1
elif [ $(tty) == /dev/tty1 ]; then
startx
# exit #to logout automatically after x closed
#if you use exit and you have autologin, it loop and restart X
/sbin/halt #to shutdown automatically after x closed
#you should sudo chmod +s /sbin/halt for this to works correctly
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment