jake@happersett: ~ /tutorials/xstuff $ _

↩ cd ..

Xstuff

Okay, you've just set up your shiny new unix box. You read followed the directions on the archwiki and installed the xorg-server package, your video driver and a fancy new window manager (try dwm, seriously). Now what?

Well, there's a lot to do still. In this article I want to go over a few of the xorg configuration files that allow you to customize the look and feel of your terminals. Specifically: the Xdefaults, Xresources and xinitrc files. Lets start:

What do these files do?

First xinitrc:

Xinitrc is simple scrpit that is read by X every time you start a new X session. It is mostly used to start window managers (and DEs) and load custom configuration files. For noobs, default settings should be copied to the users home directory via:

 $ cp /etc/X11/xinit/xinitrc ~/.xinitrc

A more in depth look at the defaults can be found elsewhere, for the scope of this tutorial its more important to understand what this files is doing. If we want to start something when we log in, we use:

exec *whateverWeWantToStart* 

So for dwm we would take out the "twm" line and put

exec dwm 

Easy huh?

Okay - lets talk Xdefaults:

Back in the day, when a Xlib program was started in an X server session it would read the contents of the ~/.Xdefaults file. This file was re-read every time a new Xlib application was opened. Generally a Xlib program is anything that starts with "X", i.e. Xterm, Xpdf (notable exception being rxvt-unicode) or runs from the terminal.

This method was innefficient and has since been superseded by the ~/.Xresources file which loads it's contents into the RESOURCE_MANAGER property of the X11 root window upon starting X. This is worth mentioning because many old tutorials will tell you to use the Xdefaults file to configure Xlib applications. Just know that anything you put in the Xdefaults file can be placed in the Xresoruces file to achieve the same effect.

So what do we do with the Xresources file?

Xresources allows many customizations to the applications running directly on the X server. Anything you run in your terminal (including the terminal itself) will gather properties from the Xresources file.

Xresources follows this basic syntax:

name.Class.resource: value

Where name is the application name, class is the classification used to group the resources,and resource is what is actually being changed. A wildcard ('*') can be used to signify that all Xapplications should use this.

For example, taken from my Xresources, this will set up the default background and foreground colors for all my terminals

 *foreground: #D7D0C7 
*background: #151515

Setting specific application settings is easy as well!

 URxvt.font: xft:Hack:size=9
URxvt.scrollBar: false
URxvt.cursorColor: #ff8939

Lets push those changes

$ xrdb ~/.Xresources

Sweet, now lets set up our xinitrc to merge these by default when you start an X session. Put this in your xinitrc (from the archwiki):

[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources

Xresources usese xrdb to load these files into the RESOURCE_MANAGER property. This is good for us as it allows us to add in settings without actually editing our Xresouces, among other things (see the manpage for said other things). For Example:

$ xrdb -merge ~/.Xdefaults

That just added our old, outdated Xdefaults to our super rad Xresources file! Cool!

This all just scratches the surface as far as what these configuration files can do. This is simply a launching point, read the manpages and the archwiki for more in depth examples.