Install and start Xorg
(This is part of a larger series on finding your footing on Arch Linux.)
Goal: Set up a minimal working graphical environment using the X Window System, the i3 window manager, and a terminal emulator of your choice; and help you understand and navigate the choices between window managers, desktop environments, and display managers.
Context: After installing of Arch and logging in, you’ll find yourself in a Linux console running a command-line shell, in which you can interact with your operating system using text-based commands. You’ll need a window system to do much more than that (e.g. run a web browser, use a standard terminal emulator, read PDFs, have windows appear on your screen, etc.). Most anything associated with modern desktop computing requires a window system.
- ArchWiki: Xorg: the server for the X Window System
- ArchWiki: xinit: used to start an X session from the login shell after a text-based login
- ArchWiki: Display manager: a GUI alternative to a text-based login that can also start X
- ArchWiki: Window manager: manages appearance of windows within a window system
- ArchWiki: Desktop environment: a bundle of desktop-related software that includes a window manager
- What’s involved
- Installing Xorg and i3
Making sense of all the Xs
Note: Feel free to skip to installation. The technical details in this section don’t matter much once you actually begin using a window system, and you usually won’t think about them or need them from the perspective of an everyday user.
Confusingly, the X window system, display server, and display server communication protocol are all called X in everyday usage. Wikipedia does a good job of explaining what’s involved; here’s my everyday-language summary:
What’s involved: A window system makes it possible for windows, icons, menus, mouse pointers, and other graphical elements to appear on a computer screen and interact with the user. The main component of a window system is a display server.
The display server is the connection point between the user and all graphical applications that display their content in a window (e.g. browsers, word processors, terminal emulators, and any other GUI application); these graphical applications are called clients of the display server. The display server and its clients communicate using a display server communication protocol.
What happens: The user, via physical input devices (keyboard, mouse, touchscreen, etc.), sends input to the operating system kernel. The display server receives this input from the operating system kernel, processes the information, and transmits it to the correct client application.
The display server also receives information from its client applications, processes it, and outputs this information as pixels to the computer screen for the user to see.
How this relates to X: The X Window System is a type of window system; Xorg is the current implementation of the display server used in the X Windows System; Xorg communicates with client applications using the X display server protocol. All of these things are colloquially called X :)
Note: the only established alternative to the X Window System is Wayland. Wayland may well replace X in the future, but at the time of writing X is still the de-facto standard for a window system. Use X if you want to follow along with the tutorials on this website.
Choices: Standalone window manager vs. desktop environment
To get a working window system, you’ll need to install both a display server and a window manager. A window manager controls the appearance, placement, stacking, tiling, etc. of windows, and will usually also provide multiple workspaces. The two common choices are:
- install a standalone window manager, or
- install a desktop environment, which will include a window manager.
A desktop environment (DE) is a bundle of well-integrated desktop-related software. A DE always includes a (potentially boring) window manager, and might also include toolbars, a dock, status bar, widgets, icons, an application launcher, a terminal emulator, a file browser, etc.
Common DEs include GNOME, KDE Plasma, and Xfce (there are many more); common standalone window managers include Bspwm, i3, and dwm (there are many more).
I lied above. You really have three choices, not two:
Install a standalone window manager, then install any desired tool bars, widgets, etc. individually. You get a cool window manager and maximum customizability. This is what I’ll do in this tutorial.
Install a DE and use its default window manager, which will do the job but might be boring. (Every DE will have a built-in window manager.) Desktop-related bells and whistles will be set up for you without requiring much work on your part.
Typical DE use case: you don’t want to install and configure its components individually, and don’t mind potentially less customizability, a larger memory footprint, and (*shudder*) a bit more “bloat”.
Install a DE and a separate stand-alone window manager, and use the stand-alone window manager instead of the default DE version. In principle you get the convenience of a DE and the full functionality of a cool window manager, but getting a DE and separate window manager to play nicely together is often difficult and best left to more advanced users.
Need help choosing a desktop environment or window manager? You can browse through a bunch of options on Ermanno Ferrari’s excellent desktop customization playlist.
Choices: Display manager or not?
It depends on how you want to log in.
After a standard Arch install you log in by typing your username and password into a text-based console prompt displayed at the end of the boot process.
After logging in, you enter a command line shell, and can then issue the
startx command to start the X Window System.
A display manager (DM) is a graphical alternative to the login process—it’s basically graphical eye candy. A DM will display a graphical login window at the end of the boot process instead of a text-based console prompt. You’ll usually get a window with GUI text fields for your username and password, and will have the option to customize colors, background wallpaper, etc. You can also configure most DMs to start Xorg automatically after logging in.
My suggestion for beginners: log in using the text-based console and leave a display manager for later—you’ll have fewer things to set up and potentially misconfigure. You can always install a DM after setting up your window manager and/or desktop environment.
Installing Xorg and i3
Here’s the minimal window setup I’ll cover on this page:
- Display server: Xorg
- Display server initialization:
- Window manager: i3
- Status bar:
- Desktop environment? No, just i3.
- Display manager? No, just
Install the following packages:
sudo pacman -S xorg xorg-xinit i3-wm i3status i3blocks
xorg is a package group—it contains the Xorg display server and a collection of other useful X-related packages;
xorg-init is used to start the X Window System;
i3-wm is the i3 window manager;
i3blocks provide the i3 status bar.
You installed X; now you need to start it—we’ll use the
startx program (provided by the
xorg-xinit package) to start the X Window System and launch a window manager.
startx’s behavior through the
We’ll use the default
xinitrc file in
/etc/X11/xinit/ as a starting point, and then change it slightly to start the window manager or desktop environment of your choice.
First make a copy of the default
xinitrcin your home directory:
# Copy the default xinitrc from /etc/X11/xinit into your home directory cp /etc/X11/xinit/xinitrc ~/.xinitrc
Open the just-copied
~/.xinitrcin a text editor, and you’ll see some boilerplate code interspersed with a mountain of empty lines. You can delete the empty lines if you like; supposedly they come from the pre-processor used to programmatically generate the
xinitrcfile—see this Arch forum discussion and this GitLab issue for a discussion of the empty lines.
Scroll to the bottom of the
~/.xinitrcand you’ll see the following code:
# At the bottom of the default xinitrc twm & xclock -geometry 50x50-1+1 & xterm -geometry 80x50+494+51 & xterm -geometry 80x20+494-0 & exec xterm -geometry 80x66+0+0 -name login
This code starts the default Tab Window Manager (
twm), a clock (
xclock), and a few instances of
xterm, which is the default X terminal emulator. The numbers just specify the screen coordinates where the clock and terminals should open.
You’ll want to replace the Tab Window Manager code block with the executable of the desktop environment or window manager you have installed and plan on using. Example: to start the i3 window manager, delete the block beginning with
twm &and replace it with the single line:
# At the bottom of the default xinitrc exec i3
(But make sure to keep all of the default
xinitrccode from above the
As a general rule, you should start long-running processes in the background by appending
&, and start the last process in the
exec, which replaces the shell process running the
xinitrcscript with the process you start with
exec, which is usually your window manager, desktop environment, or a terminal emulator. See ArchWiki: Xinit/xinitrc and this StackExchange answer for more information about the
Install a terminal emulator. I suggest Alacritty if you want to follow along with this series or xterm (the default X terminal) if you want to decide later.
sudo pacman -S alacritty # to install Alacritty sudo pacman -S xterm # to install xterm
You should install a terminal emulator now to ensure you’ll have one available after you start your first X window session. You don’t want to start X and then realize you don’t have a graphical terminal emulator available.
After creating an
xinitrcfile, you can start the X Window System by running
startxfrom the Linux console. This will dump you into a new session of your window manager or desktop environment.
If you’ve followed along with this tutorial and installed i3, you’ll probably be prompted to set your modifier key (
Altby default), and then you’ll see a blank screen with a spinning cursor. Don’t worry, nothing’s wrong—you just don’t have any windows open yet. You can start a terminal with the key combination
Modis the key you chose as your i3 modifier.
Must-do: learn the basic key bindings for controlling your window manager (if you installed i3, the official User’s Guide is a great resource).
Install more packages: consider installing a web browser (Firefox and Chromium are popular choices), an application launcher (e.g.
rofi), a media player (e.g. mpv or VLC), and a PDF/document viewer (e.g. Zathura or Okular).