8

I have a ~/.xinitrc with the following content

xrdb -merge $HOME/.Xdefaults

this xinitrc is basically useless because it's not loaded when the user logs in, I don't think that I'm doing something wrong because the same command works on the bash, my question is: does xinitrc recognize the environment variables?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
user2384250
  • 471
  • 1
  • 5
  • 8
  • Are you using something like `startx` to start X? I don't think your `.xinitrc` will be read if you are using a login manager. – phunehehe May 28 '13 at 15:38
  • @phunehehe I'm using ubuntu 13.04 64 bit – user2384250 May 28 '13 at 15:44
  • Then you are using Ubuntu's default login manager (`lightdm`). You may want to [add a start-up application](http://askubuntu.com/q/48321/1599) instead. – phunehehe May 28 '13 at 15:48
  • I am just solved alike problem: I am tried to set Awesom as my window manager, and it's Wiki recommended to use `.xinitrc`. In fact it is do not work for me, but I occasionally found that the `.xsessionrc` instead works. – Hi-Angel Oct 12 '14 at 12:30

2 Answers2

5

.xinitrc is exectued when you explicitly run xinit (startx ultimately calls xinit)to start an X-server. Mostly this doesn't happen as current Linuxes use desktop managers, which diretly start a X-Server and then run /etc/X11/Xsession <desktopenvironment>, where <desktopenvironment> is the value of any line Exec= from a file in /usr/share/xsessions, for instance

Exec=startxfce4

if you selected XFCE as sessiontype.

On at least Debian based systems the scripts in /etc/X11/Xsession.d/ are sourced (!) in order. Mostly all these scripts set stuff up and/or modify a variable STARTUP which is eventually used in the line

exec $STARTUP

So technically you could write a /usr/share/xsession/xinitrc.desktop file which lets you select a session which will run ~/.xinitrc.

Bananguin
  • 7,796
  • 2
  • 25
  • 57
  • Doesn't the display manager need X started as well? So why doesn't the display manager itself need `~/.xinitrc` prior to launching? – CMCDragonkai Aug 26 '16 at 09:44
  • 1
    Yes, display managers require an Xserver. Starting X directly, i.e., running the `Xorg` binary does not care for `~/.xinitrc`. This is what usually happens today. The DM itself does as it pleases and requires "only" a running Xserver – Bananguin Aug 31 '16 at 22:19
  • I found out that DMs have their own configuration that can run commands before the DM launches. – CMCDragonkai Sep 01 '16 at 14:49
5

~/.xinitrc is only read if you start X11 with startx (or anything that calls xinit). If you log in in graphics mode, the display manager chooses a session to start. Each session manager or desktop environment has its own startup script(s), if any.

Most systems automatically load resources from ~/.Xresources as part of the default X11 startup scripts. Try renaming your resources file to ~/.Xresources.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175