Autostart X at Login - OpenRC & SystemD
7-Jan-18: Updated OpenRC, added how to set a file immutable so as to save your /etc/conf.d/agetty.tty1 file from being overwritten during a system update. Then a 2nd edit on the same day, which shows a much better way to protect the file, using NoUpgrade = etc/conf.d/agetty.tty1 15-Dec-17: Updated the OpenRC section. It is now up to date for Artix Linux (at the least).
- 1 Auto-Login with either systemd or OpenRC
- 1.1 Autostart X at login on a systemd system
- 1.2 How to Auto-Login on an OpenRC system
- 1.3 Other Options that may be very useful
- 2 Support
Auto-Login with either systemd or OpenRC
I've dramatically updated this page, as the info' on how to autostart X at login for those using systemd was badly out of date (it still worked, but thankfully, there are easier ways to do it now). I've removed the systemd information & incorporated a link to the appropriate ArchWiki page.
I've also added a section on how to setup OpenRC to autostart X at login. Both the OpenRC & the systemd method shown on the ArchWiki should work with either WMs or DEs.
Autostart X at login on a systemd system
Before trying to automatically start
.xinitrc file, make sure to have a Proper ~/.xinitrc File.
The most up to date instructions for those systems that use the ever developing systemd can be found here on the ArchWiki: 
How to Auto-Login on an OpenRC system
Note: I tested the following on Artix using the OpenRC init.
To start X automatically:
Make your /etc/conf.d/agetty.tty1 the same as the following:
# Set the baud rate of the terminal line baud="38400" # set the terminal type term_type="linux" # extra options to pass to agetty for this port agetty_options="--autologin guest" # make agetty quiet #quiet="no"
Be sure replace guest in the above code, to the user name that you desire to autologin.
Put the following in your ~/.bash_profile :
# Start x on login if [[ -z $DISPLAY && ! -e /tmp/.X11-unix/X0 ]]; then exec startx fi
Apart from the above, you will just need to use pacman to delete sddm, lightdm or whichever other DM you have installed. After you have done that, the above changes should allow you to boot straight into your WM or DE without any user input (no logging in with user names & passwords).
Note: the above code & information came from the Porteus forum: 
If a system update makes you have to startx manually
Thus far, once, I've had an update that overwrote the /etc/conf.d/agetty.tty1 which of course meant that I had to login manually again.
All that was required (in my case) was changing the following line:
So you just have to add --autologin <your.user.name> between the double quotes & your good to go.
Two Methods that will prevent a file being upgraded over
You can stop this from happening in future by using one of the two following methods. I used the first one today, until @thefallenrat pointed me to an ArchWiki page that showed me the 2nd method, which I am now using:
Method 1. Make the agetty.tty1 file immutable
$ sudo chattr +i /etc/conf.d/agetty.tty1
If you need to make the file changeable again then do this:
$ sudo chattr -i /etc/conf.d/agetty.tty1
If you want to list the file attributes of a file that is using the second extended file system (which is what the chattr command is using), you use the following command like so:
$ lsattr /etc/conf.d/agetty.tty1
Which will give a result like so:
Method 2. Use the pacman.conf file
(quoted from the Arch Wiki)
To prevent any package from overwriting a certain file, add the following line to /etc/pacman.conf: NoUpgrade = absolute/path/to/file Note that the path must not start with a slash.
So I've uncommented the # NoUpgrade = line in my /etc/pacman.conf & it now looks like this:
NoUpgrade = etc/conf.d/agetty.tty1
So that is a much more Arch way of doing things.
Other Options that may be very useful
I've not used these methods posted in the forum by Chrysostomus, but I've put a copy of his post here for those that are interested:
Other options for systemd:
Other options for systemd and openrc:
Both of these should be faster methods, because they go directly to X without going through Getty. I haven't tested nodm, but at least xlogin is visibly faster. Bspwm edition does not have display manager, so it comes with option to enable auto login with xlogin. I'm considering moving to nodm though, because it hopefully would not depend on systemd.
Following is a link to this page's forum counterpart where you can post any related feedback: