Feature #469
Updated by Daniel Curtis about 10 years ago
While setting up an Arch box, I needed to have the ability to automatically start X and login as a given user. This guide assumes that a base Arch installation has been setup, similar to Issue #207 and logged in as root. h2. Install a Desktop Environment * Start by installing the X Window Server and extra packages: <pre> pacman -S xorg xorg-server xorg-apps xorg-xinit </pre> * Now install a desktop environment, this guide uses LXDE: <pre> pacman -S lxde </pre> h2. Set Up Automatic Login * Create a new service file similar to @getty@.service@ by copying it to @/etc/systemd/system/@: <pre> cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service </pre> * You will then have to symlink that @autologin@.service@ to the getty service for the tty on which you want to autologin, for example for tty1: <pre> ln -s /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service` </pre> * Modify the @autologin@.service@ to actually log you in automatically; change the ExecStart line to read: <pre> ExecStart=-/sbin/agetty -a USERNAME %I 38400 </pre> #* *NOTE*: Change the USERNAME to the user that will automatically be logged in as. * Tell systemd to reload its daemon files and start the service: <pre> systemctl daemon-reload systemctl start getty@tty1.service </pre> h2. Set Up Automatic X Startup * If you then want to automatically start X, edit the users @~/.bash_profile@: <pre> vi ~/.bash_profile </pre> #* And insert the following snippet at the end: <pre> if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx fi </pre> * Create a .xinitrc file: <pre> cp /etc/skel/.xinitrc ~ </pre> #* Then add the following to the end of the .xinitrc file: <pre> exec startlxde </pre> By now you should be able to run @startx@ and have a desktop environment. Now @reboot@ and check to see that the desktop environment loads up correctly. h2. Resources * https://unix.stackexchange.com/questions/42359/how-can-i-autologin-to-desktop-with-systemd