Feature #469
Automatically Start X and Login On Arch
Description
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.
Install a Desktop Environment¶
- Start by installing the X Window Server and extra packages:
pacman -S xorg xorg-server xorg-apps xorg-xinit
- Now install a desktop environment, this guide uses LXDE:
pacman -S lxde
Set Up Automatic Login¶
- Create a new service file similar to
getty
.service@ by copying it to/etc/systemd/system/
:cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service
- 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:ln -s /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
- Modify the
autologin
.service@ to actually log you in automatically:vi /etc/systemd/system/getty.target.wants/getty\@tty1.service
- Change the
ExecStart
line to read:ExecStart=-/sbin/agetty -a USERNAME %I 38400
- NOTE: Change the
USERNAME
to the user that will automatically be logged in as.
- Change the
- Tell systemd to reload its daemon files and start the service:
systemctl daemon-reload systemctl start getty@tty1.service
Set Up Automatic X Startup¶
- If you then want to automatically start X, edit the users
~/.bash_profile
:vi ~/.bash_profile
- And insert the following snippet at the end:
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx fi
- And insert the following snippet at the end:
- Create a .xinitrc file:
vi ~/.xinitrc
- Then add the following to the end of the .xinitrc file:
#!/bin/sh exec startlxde
- Then add the following to the end of the .xinitrc file:
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.
Resources¶
Updated by Daniel Curtis about 10 years ago
- Description updated (diff)
- Status changed from New to Resolved
- % Done changed from 0 to 100
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- Category set to Workstation
- Target version set to Arch Linux