I would like to accomplish the following on Arch Linux: start dhcpcd in the background on boot while simultaneously automatically logging myself in and starting the X window server.
Here's what I've tried so far. First, I enabled automatic login using the following drop in snippet to getty@tty1:
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin username --noclear %I $TERM
I also added exec startx
to my .bash_profile file. Together, these successfully log me in on boot and start X
Next, I enabled the dhcpcd service using systemctl: sudo systemctl enable dhcpcd@enp4s0.service
(enp4s0 is my ethernet port). This successfully starts dhcpcd and then logs me in. However, the login prompt is delayed by about 10 seconds while the connection is set up, which is a little annoying. I would like dhcpcd connection to happen in the background while I am presented with an X environment.
So, I added After=getty@tty1
to the dhcpcd service file by running sudo systemctl edit dhcpcd@enp4s0.service
and creating the following snippet:
[Unit]
After=getty@tty1.service
After this, I am no longer presented with a login screen on boot, and checking the logs reveals that systemd detected a dependency loop and never started getty.
Presumably this is because getty has the type "idle," which means it starts last in the job order. So I set Type=simple
in the getty service file. However, I now receive the error that unprivileged users are not allowed to login on boot and never get to a login prompt. I am unsure how to proceed.
I realize one solution is to just put the dhcpcd in my bash_profile. However, is there any way to accomplish what I want using systemd alone? I may want to run other services this way in the future and I would prefer not to clutter up my bash_profile.