blog of pesa

.Xdefaults vs .Xresources

Many X programs have user-level configuration options that can be set in the X server’s resource database.

The two most common ways to achive persistent configuration for your X programs are to store them in either ~/.Xdefaults or ~/.Xresources files.

I will not go into detail of the syntax of these files. However, there are some things to take into consideration between the choice of the two files.

Consider the X program xterm. You want to make the background black and the foreground white. This can be achived by passing some command line arguments to xterm:

$ xterm -bg black -fg white

This is fine if you want this for only one time, but if you want it to be the default you put it in a configuration file.

XTerm*background: black
XTerm*foreground: white

If you put this in the ~/.Xdefaults file you will notice that the next time you start an xterm it has the new colors. Great! Or, is it?
It is easy to change configuration options and it will be in effect next time you start the program, but it comes at the cost that basically all X programs needs to parse this file everytime you run one.

A better way is to put the configuration options in the ~/.Xresources file and store the configuration in the X server’s resource database by using the xrdb command:

$ xrdb -merge ~/.Xresources

Doing this, (in simple terms) xterm will “ask” the X server for its resource options rather than reading a file. This is much quicker and avoids unnecessary reads on disk.
Another great thing about this is that remote X programs (e.g., tunneled through SSH) will be able to catch these options.

Once configurations are read into the X server’s resource databse (using xrdb), X programs should not look for configuration options in ~/.Xdefaults file.

As many desktop environments (like Gnome or KDE) will store the configurtion from both files into the resource database upon the start of X, the drawbacks stated above may not be a problem.
However, if you don’t run a desktop environment (like me) you need to manually run xrdb when starting X (e.g., by adding xrdb command line above to the ~/.xinitrc file).

If you run xrdb manually, you can of course name the ~/.Xresources file whatever you want, but it’s the defacto standard.

This entry was posted on Saturday, January 14th, 2012 at 20:09 and is filed under HowTo, Linux, Tools, X. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« Experimenting with window managers

11 Responses to “.Xdefaults vs .Xresources”

  1. Multi head by catalyst – Huge mouse cursor/pointer issue in openbox | Notes Says:
    March 27th, 2014 at 23:25

    […] better way to fix this problem would be the xrdb -merge. But I won’t go into this too […]

  2. henk Says:
    May 9th, 2015 at 21:58

    Thanks you very much for your explaination.
    Have been struggling a long time with xterm to get a bigger font. Now i undertand how it should work and why. Installed xrdb and everything is running just fine now.

  3. Speakerzhq Says:
    March 29th, 2019 at 10:49

    ???????,??????????! .

  4. Jamesetero Says:
    June 26th, 2019 at 00:46

    Купить права в Санкт-Петербурге – Купить права тракориста, права водителя

  5. Paid Studies: Gain $7864 Or More Weekly: https://get-2-btc-per-day.blogspot.ae?r=65 Says:
    November 21st, 2019 at 12:25

    Invest $ 2427 and get $ 7449 every month: https://make-5-btc-per-day.blogspot.de?z=59

  6. Не стандартный способ заработка денег в интернете от 5211 rubley в день: https://slimex365.com/zarabotaymillion403338 Says:
    November 25th, 2019 at 13:01

    Заработок в интернете от 8695 rub. в день: http://milehearan.tk/uhyal

  7. större kuk Says:
    December 4th, 2019 at 12:23

    This web site really has all of the information I wanted about this subject and didn’t know
    who to ask.

  8. OlegCauche Says:
    January 21st, 2020 at 00:08

    Регистрация

  9. ЕASY SCHЕМЕ ЕARNINGS ON THE INТERNЕT from $5542 рer day: http://nsiy.daylibrush.com/25188e3 Says:
    March 10th, 2020 at 18:48

    Нow to invеst in Вitcоin $ 7874 – gеt а rеturn of uр to 5143%: http://qfxrj.daylibrush.com/19d683

  10. DavidMoila Says:
    July 31st, 2020 at 01:29

    магазин продажи аккаунтов – Купить канал Телеграмм, Гарант сервис онлайн

  11. Yvsqhmw Says:
    August 24th, 2020 at 10:07

    Upoltvp

    iason.002@gmail.com
    :

Leave a Reply

  • Pages

    • About
  • Archives

    • January 2012
    • July 2009
    • September 2007
  • Categories

    • HowTo
    • Linux
    • Programming
    • Security
    • Tools
    • Uncategorized
    • X
  • Blogroll

    • blog.dabi.se
    • blog.padowi.se

blog of pesa is proudly powered by WordPress | Bob