On Unix-like operating systems, the xrdb command is the X window server resource database utility.
Description
If you are configuring the X windowing system for use on multiple clients, the xrdb program can be useful by helping you maintain multiple resource files in one unified resource database. The resources are stored on the X server, where they are accessible to any clients that connect to that server.
- Description
- Syntax
- Syntax of an x resource
- Examples
- Related commands
- Linux commands help
The xrdb command can run interactively from the command line, or it can be included in your .xinitrc or .xsession file so that it initializes resources at login.
Syntax
xrdb [-option …] [file name]
The file name is optional, and specifies a file which contains the values of client variables (“resources”) to be read. If no file name is specified, xrdb will expect these values to be provided via standard input. xrdb will overwrite its values with whatever you provide; so, if you run xrdb with no file name (starting it in interactive mode), and then enter no values, any values already loaded by your init scripts will be overwritten as valueless.
The values can be stored in a file named anything at all, but the file is commonly named .Xresources or .Xdefaults. .Xdefaults is a deprecated name in modern implementations; .Xresources is the preferred file name.
.Xresources is often loaded with xrdb automatically when xinit is called by your startup script. But if you’d like to make changes to the resource database manually, or change how xrdb is invoked in your scripts, you can invoke xrdb with these options.
Options
Syntax of an x resource
The general form of an X resource entry is:
name.Class.resource: value
- The name is the name of the application, for instance “xterm” or “xscreensaver”.
- The class is the class of resources, such as “Dialog” or “Scrollbar”. The name of a class often starts with an uppercase letter.
- The resource is the name of the resource of the named application, in the resource class specified, to be changed. Resource names are often in “camel case”, they start with a lowercase letter, and use uppercase letters in the name when there is a new word. For instance, “buttonFont”.
- The value is the value of the resource.
So, the following resource entry would set the resource “foreground”, of the “Dialog” class of resources, of the application “xscreensaver”:
xscreensaver.Dialog.foreground: #101010
With this resource value set, the dialog boxes of the xscreensaver application has the hexadecimal color value #101010. Classes can also have sub-classes. For instance, the screensaver “Dialog” class has a sub-class “Button”, that also takes a color value. To set the foreground resource to the same gray color, you could use the line:
xscreensaver.Dialog.Button.foreground: #101010
Using comments in your resource file
If a line in your resource file starts with an exclamation point “!”, it will considered a comment and ignored by xrdb. So, you could include these lines in your resource file, for instance:
! My favorite xscreensaver dialog and button foreground colors: light gray xscreensaver.Dialog.Button.foreground: #101010 screensaver.Dialog.foreground: #101010
Using wildcards
xrdb will interpret an asterisk ("*") as a wildcard, similar to using the asterisk when specifying file names in a shell. For instance, to set all xscreensaver “Dialog” resources to the same value, you could use the line:
xscreenaverDialog: #101010
…or, to set the “Dialog” resources for every application:
Dialog: #101010
Examples of typical resources
Xft, the application which controls the rendering of fonts in X, can be configured with the following standard resources values:
Xft.dpi: 96 Xft.antialias: true Xft.rgba: rgb Xft.hinting: true Xft.hintstyle: hintslight
xterm is the default X terminal emulator. Typical resource values for xterm include:
xtermVT100.geometry: 80x25 xtermfaceName: Courier:style=Regular:size=10 xtermdynamicColors: true xtermutf8: 2 xtermeightBitInput: true xtermsaveLines: 512 xtermscrollKey: true xtermscrollTtyOutput: false xtermscrollBar: true xtermrightScrollBar: true xtermjumpScroll: true xtermmultiScroll: true xterm*toolBar: false
You can find the names of additional xterm resources and their values in our xterm documentation. In general, when configuring an X application’s resources, it’s a good idea to consult the application’s man page for details.
Examples
xrdb
Open the server resource database utility in interactive mode. Values can be entered manually, and you can enter Ctrl-D when you are finished to be returned to the command line. If you enter nothing, any values already stored in the database will be removed.
Entering the values manually is the least-convenient way to access the resource database, and it’s easy to make a typo. It’s more common is to load values from a resource file, as in the next example.
xrdb -load ~/.Xresources
Load the file .Xresources in your home directory and write the values contained in it to the database. This command is often performed automatically when you start an X session, but this command will force a re-load of the resource values contained in the file, overwriting any other values stored in the database.
xrdb -query
Query the resource database to see what variables and values are currently set. Output resembles the following sample contents of an X resources file:
dialogvaluebackground: white DialogLabelfont: -adobe-helvetica-bold-r---12-------* MenuButtonfont: -adobe-helvetica-medium-r---12-------* MenuButtonbackground: grey80 MenuButtonforeground: black Label.font: -adobe-helvetica-medium-r---10------- LabelshadowWidth: 1 SmeBSB.font: -adobe-helvetica-bold-r---12------- SimpleMenufont: -adobe-helvetica-medium-r---10-------* OptionMenufont: -adobe-helvetica-medium-r---10-------* Command.font: -linotype-helvetica-bold-r-narrow--12-------* Toggle.font: -adobe-helvetica-bold-o---12------- Form.background: grey70 TransientShellDialog.background: grey70 Scrollbar.Foreground: grey80 Scrollbar.Background: grey50 ScrollbarcursorName: top_left_arrow Scrollbarwidth: 16 shapeStyle: Rectangle XlwMenu.shadowThickness: 1 shadowWidth: 1 xtermscrollbar.background: grey40 xtermforeground: grey90 xtermbackground: grey25 xtermcursorColor: white xtermvisualbell: on rxvtcolor12: steelblue rxvtcolor15: white rxvtcolor9: rgb:ff/7f/5f rxvtforeground: grey90 rxvtbackground: grey10 rxvtcursorColor: white rxvtfont: lucidasanstypewriter-12 rxvtloginShell: false rxvtsaveLines: 1024 rxvttitle: shell rxvtgeometry: 80x2 xmantopBox: false xmanbackground: lightsteelblue xmanforeground: black xcalcCommand.font: -adobe-helvetica-bold-r---10-------* xcalc*customization: -color
xrdb -merge my-xr-values
Merge the values listed in the file my-xr-values with any resource values currently stored in the database. This command is an alternative to overwriting all values with -load, for instance.
You could also use the -merge option without a file name, in which case you could manually enter a value (or values) and your entry would be merged with values already in the database. For instance, if you run
xrdb -merge
…and then type:
xterm.AllowBoldFonts.allowBoldFonts: true
…and then press Ctrl+D to terminate the entry, your resource database would store that value to the database, without removing any previous values stored. Any subsequent xterm sessions would use this value, and display bold font faces if called for.
Related commands
startx — Start an X Window System session.X — Executable of the X Window System.xinit — The initializer of the X Window System.