Project

General

Profile

Feature #469

Automatically Start X and Login On Arch

Added by Daniel Curtis almost 3 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Workstation
Target version:
Start date:
10/05/2014
Due date:
% Done:

100%

Estimated time:
1.00 h
Spent time:

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.
  • 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
      
  • Create a .xinitrc file:
    vi ~/.xinitrc
    
    • Then add the following to the end of the .xinitrc file:
      #!/bin/sh
      exec startlxde
      

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

History

#1 Updated by Daniel Curtis almost 3 years ago

  • Description updated (diff)
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#2 Updated by Daniel Curtis almost 3 years ago

  • Status changed from Resolved to Closed

#3 Updated by Daniel Curtis almost 2 years ago

  • Description updated (diff)

#4 Updated by Daniel Curtis almost 2 years ago

  • Description updated (diff)
  • Category set to Workstation
  • Target version set to Arch Linux

Also available in: Atom PDF