Automatic Login to Graphical Environment

From Void Linux Wiki
Jump to: navigation, search

Related articles

Booting to a GUI without login is handy in certain situations. One such situation is on a HTPC. This article details a couple methods for accomplishing this task.

Using a display manager

  • autox — Most-minimalistc, ~150 lines of C, logs in a specified user and runs xinit.
https://github.com/jsumners/autox || autox
  • nodm — Minimalistic display manager for automatic logins.
https://github.com/spanezz/nodm || nodm

Automatic Login On TTY1

Create a new autologin service:

 cp -R /etc/sv/agetty-tty1 /etc/sv/agetty-autologin-tty1

Note: The name of the custom service file must end with -tty1 (or another valid port). Otherwise the run-script will not work.

Edit /etc/sv/agetty-autologin-tty1/conf:

 GETTY_ARGS="--autologin yourusernamehere --noclear"
 BAUD_RATE=38400
 TERM_NAME=linux

If you are logged in on tty1 right now, logout, switch to tty2 (with CTRL+ALT+F2) and re-login there.

Disable the regular tty1 service and enable autologin:

 rm /var/service/agetty-tty1
 ln -s /etc/sv/agetty-autologin-tty1 /var/service

Now switch to tty1 and you should already be logged in there automatically.

Autostart Graphical Environment on Login

Add the following to your shell's profile file to start X and lock the tty session:

 # autologin on tty1
 if [ -z "$DISPLAY" ] && [ "$(fgconsole)" -eq 1 ]; then
 exec startx
 fi

Notes:

  • If after having exited the X session, you'd like to be logged into tty1 without relaunching X, omit the exec command.
  • If you're using startx, check if you have it installed (it's in xinit). startx will read your .xinitrc, you should put your desired desktop environment in there.
  • You can replace startx with the name of a wayland compositor, that you have installed. For example weston or sway.