## Wednesday, July 1, 2009

### The (not-so) secret of .Xdefaults (or rather, .Xresources)

Several people commented that .Xdefaults—the original subject of the post—is an obsolete file, and that .Xresources should be used instead. I stand corrected, and so does the blog post.

There's a startling amount of people who have missed out on a pretty integral part of X11, namely the X resources database.

What the xrdb does is allow you to set various settings that you would otherwise have to pass with command line arguments to the programs. Clearly, it's pretty cumbersome to start xterm with the command xterm -fg gray -bg black just to escape the horrors of the black on white default color settings on xterm. Reverse video makes the defaults marginally less painful, but the contrast is still not particularly endearing.

Figure 1: A change of defaults makes a world of difference.

There's a wonderful file named ~/.Xresources that allows you to get around this. It is loaded automatically when the X session starts, and can be forced to reload with xrdb -merge ~/.Xresources

My .Xresources file looks like this:
XTerm*background: blackXTerm*foreground: grayXTerm*title: terminalXTerm*saveLines: 1024

If you read the man page for xterm, you'll find a rather intimidating list of settings you can alter with .Xresources.

.

1. I think .Xresources has replaced .Xdefaults now. (At least in $HOME). According to a bug report in Debian (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=108394), the Xsession man page explains it as such: "$HOME/.Xresources contains X resources specific to the invoking user's environment. The settings are loaded with xrdb -merge. Note that \$HOME/.Xdefaults is a relic from X Ver­sion 10 (and X11R1) days, before app-defaults files were implemented. .Xresources should