You are not logged in.

#1 2016-02-14 08:25:32

Kirkx
Member
Registered: 2015-04-16
Posts: 17

[SOLVED] .xinitrc and .Xresources

I'm using startx to start i3-wm and also have ~/.Xresources file with some basic Xterm configuration.

According to the Wiki you need to add the following line to your ~/.xinitrc file:

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

https://wiki.archlinux.org/index.php?ti … to_xinitrc

1) Can the script shown above be made more simple? I have created .Xresources myself so I don't need the script to confirm that it is present on the system.

2) Does xrdb parameter really need to be xrdb -merge and not xrdb -load? I'm just trying to load Xterm settings when starting WM.

3) I can't figure out what I$HOME is supposed to do.

Here is my version of this line, and it works just fine:

xrdb -load ~/.Xresources

or

xrdb -load $HOME/.Xresources

I don't know much about bash scripts for now, so any guidance from the experts would be appreciated.

----------
Here is my ~/.xinitrc and ~/.Xresources:

~/.xinitrc

#!/bin/sh

# initialize X resource database (if file ~/.Xresources is present on the system)
# [[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources
# xrdb -merge ~/.Xresources

xrdb -load ~/.Xresources

if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

exec i3

~/.Xresources

! Xterm
! Fonts
! xterm*font: 7x13
! xterm*font: 7x14
xterm*faceName: DejaVu Sans Mono Book
xterm*faceSize: 9

! Make every shell a login shell (to include all necessary environment variables)
xterm*loginshell: true

! Scrollback limit
xterm*savelines: 2048

! double-click to select whole URLs
! xterm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48

! DOS-box colours
xterm*foreground: rgb:54/fc/54
xterm*background: rgb:00/00/00

! Blinking cursor
xterm*cursorBlink: true

! right scrollbar (default is left)
! xterm*ScrollBar: true
! xterm*rightScrollBar: true

! stop output to terminal from jumping down to bottom
! xterm*scrollTtyOutput: false

Last edited by Kirkx (2016-02-15 08:48:54)

Offline

#2 2016-02-14 09:33:04

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: [SOLVED] .xinitrc and .Xresources

Are you trying to overcomplicate things?  Do yo actually need to merge .Xresources separately when using the .xinitrc?

The "-I$HOME" is simply specifying a directory.  Check the Wiki and the manpage is you are not 100% sure.


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#3 2016-02-14 09:33:36

null
Member
Registered: 2009-05-06
Posts: 398

Re: [SOLVED] .xinitrc and .Xresources

1) yes. The part after && is enough.
2) man 1 xrdb
3) man 1 xrdb (where $HOME is the bash variable containing the path to your home directory. Probably /home/<yourname>. You can always do a `echo $HOME` in your teminal to get the content)

Offline

#4 2016-02-14 10:40:53

Kirkx
Member
Registered: 2015-04-16
Posts: 17

Re: [SOLVED] .xinitrc and .Xresources

1)

null
1) yes. The part after && is enough.

Thanks for clarification.

2) As I googled around I was under the impression that xrdb -merge is only used if you want to make changes on the live system. Beyond that xrdb -load would be used.

man xrdb

-load
This option indicates that the input should be loaded as the new value of the specified properties, replacing whatever was there (i.e. the old contents are removed). This is the default action.

-merge
This option indicates that the input should be merged and lexicographically sorted with, instead of replacing, the current contents of the specified properties.

Do the "contents of the specified properties" persist after you exit xorg server or shutdown the computer? If so, then when using xrdb -merge the "contents" would keep growing indefinitely as you keep restarting xorg.

3) I think I have found the answer. -I$HOME seems to be required only if you put #include at the beginning of the script to reference some other configuration files:

man xrdb (the last line in Options section)

-Idirectory
This option is passed through to the preprocessor and is used to specify a directory to search for files that are referenced with #include.

Offline

#5 2016-02-14 10:51:27

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] .xinitrc and .Xresources

Yes, -load is fine if you load all your settings at once. And since it's the default action, you don't even need to specify it (if you're going for simple/short). These settings don't persist after exiting X.

You have found the anser for the -I parameter. I wonder if that's necessary, though. Normally the preprocessor would look in the directory containing the source file and in the wiki example the .Xresources file is in $HOME. It might be needed in specific cases, but it seems odd to include it in such a general recommendation.

Offline

#6 2016-02-14 11:24:21

Kirkx
Member
Registered: 2015-04-16
Posts: 17

Re: [SOLVED] .xinitrc and .Xresources

Thanks. So to sum up, the line currently in the wiki might be useful under some specific circumstances, but the simple code below will be sufficient in most cases:

All four versions are equivalent:

xrdb -load ~/.Xresources
xrdb -load $HOME/.Xresources
xrdb ~/.Xresources
xrdb $HOME/.Xresources

Offline

#7 2016-02-14 12:11:34

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,763
Website

Re: [SOLVED] .xinitrc and .Xresources

You can also remove the if block that checks for the presence of /etc/X11/xinit/xinitrc.d -- you already know you have that as well wink

From:

if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

To:

for f in /etc/X11/xinit/xinitrc.d/*; do
   [ -x "$f" ] && . "$f"
done
unset f

You might get back a hot millisecond or three from this big_smile

Offline

#8 2016-02-15 08:46:38

Kirkx
Member
Registered: 2015-04-16
Posts: 17

Re: [SOLVED] .xinitrc and .Xresources

Head_on_a_Stick: You can also remove the if block that checks for the presence of /etc/X11/xinit/xinitrc.d -- you already know you have that as well

Thanks for your suggestion. Marking the thread as solved. For the record, here is my lean .xinitrc

~/.xinitrc

#!/bin/sh

# initialize X resource database (if file ~/.Xresources is present on the system)
xrdb -load ~/.Xresources

for f in /etc/X11/xinit/xinitrc.d/?*.sh; do
    [ -x "$f" ] && . "$f"
done
unset f

exec i3

Last edited by Kirkx (2016-03-06 10:44:00)

Offline

Board footer

Powered by FluxBB