X resources

From ArchWiki
(Redirected from Xdefaults)
Jump to: navigation, search

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: See Help:Style (Discuss in Talk:X resources#)

Xresources is a user-level configuration dotfile, typically located at ~/.Xresources. It can be used to set X resources, which are configuration parameters for X client applications.

They can do many operations, including:

  • defining terminal colours
  • configuring terminal preferences
  • setting DPI, antialiasing, hinting and other X font settings
  • changing the Xcursor theme
  • theming xscreensaver
  • altering preferences on low-level X applications (xclock (xorg-xclock), xpdf, rxvt-unicode, etc.)


Install the xorg-xrdb package.


Load resource file

Resources are stored in the X server, so have to only be read once. They are also accessible to remote X11 clients (such as those forwarded over SSH).

Load a resource file (such as the conventional .Xresources), replacing any current settings:

$ xrdb ~/.Xresources

Load a resource file, and merge with the current settings:

$ xrdb -merge ~/.Xresources
  • Most Display managers will load the ~/.Xresources file on login.
  • The older ~/.Xdefaults file is read when an X11 program starts, but only if xrdb has not been used in the current session. [1]


If you are using a copy of the default xinitrc as your .xinitrc it already merges ~/.Xresources.

If you are using a custom .xinitrc add the following line:

[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources
Warning: Never background the xrdb command within ~/.xinitrc. Otherwise, programs launched after xrdb may look for resources before it has finished loading them.

Default settings

To see the default settings for your installed X11 apps, look in /usr/share/X11/app-defaults/.

Detailed information on program-specific resources is usually provided in the man page for the program. xterm's man page is a good example, as it contains a list of X resources and their default values.

To see the current loaded resources:

xrdb -query -all

Xresources syntax

Basic syntax

The syntax of an Xresources file is as follows:

name.Class.resource: value

and here is a real world example:

xscreensaver.Dialog.headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
The name of the application, such as xterm, xpdf, etc
The classification used to group resources together. Class names are typically uppercase.
The name of the resource whose value is to be changed. Resources are typically lowercase with uppercase concatenation.
The actual value of the resource. This can be 1 of 3 types:
  • Integer (whole numbers)
  • Boolean (true/false, yes/no, on/off)
  • String (a string of characters) (for example a word (white), a color (#ffffff), or a path (/usr/bin/firefox))
A dot (.) is used to signify each step down into the hierarchy — in the above example we start at name, then descend into Class, and finally into the resource itself. A colon (:) is used to separate the resource declaration from the actual value.

Wildcard matching

The asterisk can be used as a wildcard, making it easy to write a single rule that can be applied to many different applications or elements.

Using the previous example, if you want to apply the same font to all programs (not just XScreenSaver) that contain the class name Dialog which contains the resource name headingFont, you would write:

*Dialog.headingFont:     -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1

If you want to apply this same rule to all programs that contain the resource headingFont, regardless of its class, you would write:

*headingFont:    -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1


To add a comment to your Xresources file, simply prefix it with an exclamation mark (!), for example:

! The following rule will be ignored because it has been commented out
!Xft.antialias:        true

Include files

To use different files for each application, use #include in the main file. For example:

#include ".Xresources.d/xterm"
#include ".Xresources.d/rxvt-unicode"
#include ".Xresources.d/fonts"
#include ".Xresources.d/xscreensaver"

If files fail to load, specify the directory to xrdb with the -I parameter. For example:

xrdb -I$HOME ~/.Xresources

Sample usage

The following samples should provide a good understanding of how application settings can be modified using an Xresources file. See [2] for more examples. Refer to the man page of the application in question otherwise.

Terminal colors

Most terminals, including xterm and urxvt, support at least 16 basic colors. The colors 0-7 are the 'normal' colors. Colors 8-15 are their 'bright' counterparts, used for highlighting.

! Black + DarkGrey
*color0:  #000000
*color8:  #555753
! DarkRed + Red
*color1:  #ff6565
*color9:  #ff8d8d
! DarkGreen + Green
*color2:  #93d44f
*color10: #c8e7a8
! DarkYellow + Yellow
*color3:  #eab93d
*color11: #ffc123
! DarkBlue + Blue
*color4:  #204a87
*color12: #3465a4
! DarkMagenta + Magenta
*color5:  #ce5c00
*color13: #f57900
!DarkCyan + Cyan (both not tango)
*color6:  #89b6e2
*color14: #46a4ff
! LightGrey + White
*color7:  #cccccc
*color15: #ffffff

See man page#Colored man pages on xterm or rxvt-unicode for how to color bold and underlined text automatically xterm and rxvt.

Warning: Color resources such as foreground and background can be read by other applications (such as emacs). This can be avoided by specifiying the class name, for example XTerm.foreground.


See Cursor themes#X resources.


See Font configuration#Applications without fontconfig support.


See Xterm#Configuration.


See Rxvt-unicode#Configuration.


See Options in man xpdf.

Color scheme commands

Here are some fast bash commands you can run right in your shell.

Display all 256 colors

Prints all 256 colors across the screen, very quick.

(x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)

Display tput escape codes

Replace tput op with whatever tput you want to trace. op is the default foreground and background color.

$ ( strace -s5000 -e write tput op 2>&2 2>&1 ) | tee -a /dev/stderr | grep -o '"[^"]*"'

Enumerating colors supported by terminals

The following command will let you discover all the terminals you have terminfo support for, and the number of colors each terminal supports. The possible values are: 8, 15, 16, 52, 64, 88 and 256.

$ for T in `find /usr/share/terminfo -type f -printf '%f '`;do echo "$T `tput -T $T colors`";done|sort -nk2
Eterm-88color 88
rxvt-88color 88
xterm+88color 88
xterm-88color 88
Eterm-256color 256
gnome-256color 256
konsole-256color 256
putty-256color 256
rxvt-256color 256
screen-256color 256
screen-256color-bce 256
screen-256color-bce-s 256
screen-256color-s 256
xterm+256color 256
xterm-256color 256

Enumerating terminal capabilities

This command is useful to see what features that are supported by your terminal.

$ infocmp -1 | sed -nu 's/^[ \000\t]*//;s/[ \000\t]*$//;/[^ \t\000]\{1,\}/!d;/acsc/d;s/=.*,//p'|column -c80
bel	cuu	ich	kb2	kf15	kf3	kf44	kf59	mc0	rmso	smul
blink	cuu1	il	kbs	kf16	kf30	kf45	kf6	mc4	rmul	tbc
bold	cvvis	il1	kcbt	kf17	kf31	kf46	kf60	mc5	rs1	u6
cbt	dch	ind	kcub1	kf18	kf32	kf47	kf61	meml	rs2	u7
civis	dch1	indn	kcud1	kf19	kf33	kf48	kf62	memu	sc	u8
clear	dl	initc	kcuf1	kf2	kf34	kf49	kf63	op	setab	u9
cnorm	dl1	invis	kcuu1	kf20	kf35	kf5	kf7	rc	setaf	vpa

Color scheme scripts

Any of the following scripts will display a chart of your current terminal color scheme. Handy for testing and whatnot.


#!/usr/bin/env lua

function cl(e)
	return string.format('\27[%sm', e)

function print_fg(bg, pre)
	for fg = 30,37 do
		fg = pre..fg
		io.write(cl(bg), cl(fg), string.format(' %6s ', fg), cl(0))

for bg = 40,47 do
	io.write(cl(0), ' ', bg, ' ')
	print_fg(bg, ' ')
	io.write('\n    ')
	print_fg(bg, '1;')

-- Andres P


# ANSI color scheme script featuring Space Invaders
# Original: http://crunchbang.org/forums/viewtopic.php?pid=126921%23p126921#p126921
# Modified by lolilolicon

f=3 b=4
for j in f b; do
  for i in {0..7}; do
    printf -v $j$i %b "\e[${!j}${i}m"

cat << EOF

 $f1  ▀▄   ▄▀     $f2 ▄▄▄████▄▄▄    $f3  ▄██▄     $f4  ▀▄   ▄▀     $f5 ▄▄▄████▄▄▄    $f6  ▄██▄  $rst
 $f1 ▄█▀███▀█▄    $f2███▀▀██▀▀███   $f3▄█▀██▀█▄   $f4 ▄█▀███▀█▄    $f5███▀▀██▀▀███   $f6▄█▀██▀█▄$rst
 $f1█▀███████▀█   $f2▀▀███▀▀███▀▀   $f3▀█▀██▀█▀   $f4█▀███████▀█   $f5▀▀███▀▀███▀▀   $f6▀█▀██▀█▀$rst
 $f1▀ ▀▄▄ ▄▄▀ ▀   $f2 ▀█▄ ▀▀ ▄█▀    $f3▀▄    ▄▀   $f4▀ ▀▄▄ ▄▄▀ ▀   $f5 ▀█▄ ▀▀ ▄█▀    $f6▀▄    ▄▀$rst

 $bld$f1▄ ▀▄   ▄▀ ▄   $f2 ▄▄▄████▄▄▄    $f3  ▄██▄     $f4▄ ▀▄   ▄▀ ▄   $f5 ▄▄▄████▄▄▄    $f6  ▄██▄  $rst
 $bld$f1█▄█▀███▀█▄█   $f2███▀▀██▀▀███   $f3▄█▀██▀█▄   $f4█▄█▀███▀█▄█   $f5███▀▀██▀▀███   $f6▄█▀██▀█▄$rst
 $bld$f1▀█████████▀   $f2▀▀▀██▀▀██▀▀▀   $f3▀▀█▀▀█▀▀   $f4▀█████████▀   $f5▀▀▀██▀▀██▀▀▀   $f6▀▀█▀▀█▀▀$rst
 $bld$f1 ▄▀     ▀▄    $f2▄▄▀▀ ▀▀ ▀▀▄▄   $f3▄▀▄▀▀▄▀▄   $f4 ▄▀     ▀▄    $f5▄▄▀▀ ▀▀ ▀▀▄▄   $f6▄▀▄▀▀▄▀▄$rst



                              $f7    ▄█▄    $rst



#!/usr/bin/env ruby
# coding: utf-8
# ANSI color scheme script 
# Author: Ivaylo Kuzev < Ivo >
# Original: http://crunchbang.org/forums/viewtopic.php?pid=134749%23p134749#p134749
# Modified using Ruby.
CL = "\e[0m"
BO = "\e[1m"

R = "\e[31m" 
G = "\e[32m"
Y = "\e[33m"
B = "\e[34m"
P = "\e[35m"
C = "\e[36m"
print <<EOF 
#{BO}#{R}  ██████  #{CL} #{BO}#{G}██████  #{CL}#{BO}#{Y}   ██████#{CL} #{BO}#{B}██████ #{CL}  #{BO}#{P}  ██████#{CL} #{BO}#{C}  ███████#{CL}
#{BO}#{R}  ████████#{CL} #{BO}#{G}██    ██ #{CL}#{BO}#{Y}██ #{CL}      #{BO}#{B}██    ██#{CL} #{BO}#{P}██████ #{CL} #{BO}#{C} █████████#{CL}
#{R}  ██  ████#{CL} #{G}██  ████#{CL}#{Y} ████    #{CL} #{B}████  ██#{CL} #{P}████ #{CL}    #{C}█████ #{CL}
#{R}  ██    ██#{CL} #{G}██████ #{CL}#{Y}  ████████#{CL} #{B}██████ #{CL}  #{P}████████#{CL} #{C}██ #{CL}


Parsing errors

Display managers such as GDM and LightDM may use the --nocpp argument for xrdb. See LightDM#Xresources not being parsed correctly.

See also