The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
2

How do xsession, xinitrc and .i3/config play together?

asked 2012-06-04 15:56:48 +0000

Michael gravatar image

updated 2012-07-02 20:01:13 +0000

joepd gravatar image

There are three different ways of starting programs after logging in: ~/.xsession, ~/.xinitrc and ~/.i3/config (or the path to your i3 config file). What’s the difference?

edit retag flag offensive close merge delete

Comments

Also see this related question: [Session's environment variables](https://faq.i3wm.org/question/4126/sessions-environment-variables/).

Hibou57 gravatar imageHibou57 ( 2014-07-05 03:19:35 +0000 )edit

2 answers

Sort by » oldest newest most voted
2

answered 2012-06-07 15:06:11 +0000

updated 2012-06-07 15:09:10 +0000

Michael has already explained the difference, but I'd like to add a few notes of background (IMHO, it's good to understand how things work step by step):

Based on The X Window User HOWTO:

  1. startx will start X by first invoking xinit.
  2. xinit will look for a ~/.xinitrc file in the user's home directory, to run as a shell script.
  3. xinitrc is used to set up a suitable X environment, and to launch other programs, a.k.a "clients" that we may want available as soon as X is started.
  4. The Window Manager, or desktop environment, is typically the last application started.
  5. The other, more common, approach is the "GUI log-in", where X is running before log-in. X includes xdm (X Display Manager) for this purpose.
  6. Now, ~/.xsession for xdm is the rough equivalent of ~/.xinitrc for startx.
  7. Depending on how you start X, either the ~/.xinitrc or the ~/.xsession file will be executed by the server.
  8. Finally, if you execute i3wm from ~/.xinitrc or ~/.xsession, then i3wm will read its initial configuration from ~/.i3/config.
  9. Done.

Given that, you may like to maintain single version of your personal startup script for X:

  • Create the script ~/.xinitrc with your initial settings.
  • Make symbolic link for xdm equivalent:

    $ ln -s $HOME/.xinitrc $HOME/.xsession

Also, Fluxbox manual includes an important explanation too:

When X11 is started, your .xinitrc or .xsession script is run, and when the script is done, X11 comes down. Let me repeat that, its important: when .xinitrc is finished, that is when X ends. It isn't when your window manager exits.*

edit flag offensive delete link more

Comments

Actually, `~/.xsession` seems to be ignored with a GDM login, so that does not make it an option for Ubuntu users.

Hibou57 gravatar imageHibou57 ( 2014-07-05 02:12:38 +0000 )edit
1

answered 2012-06-04 16:00:08 +0000

Michael gravatar image

You have to differentiate between what gets started after you log in but before you start i3:

  • ~/.xsession is the way to go when using a login manager (like gdm, kdm, xdm).
  • ~/.xinitrc will be used when you use startx

The i3 configuration (usually ~/.i3/config) will of course be used in either case, additionally.

So, where should you put your auto-start entries?

  • If you are setting a background image, you can do that in any place (either before i3 starts or afterwards).
  • If you are launching a program, you should do that in your i3 configuration so that it will be launched with startup notification support.
edit flag offensive delete link more

Comments

`~/.xession` seems to be ignored with GDM on Ubuntu 12.04. I tried to define an environment variable with `export FOO=bar` in a newly created `.xession` (there was none), and `echo $FOO` from a terminal displays nothing, which suggests this file is not sourced.

Hibou57 gravatar imageHibou57 ( 2014-07-05 02:14:46 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2012-06-04 15:56:48 +0000

Seen: 10,188 times

Last updated: Jun 07 '12