The .xinitrc file is really just one more shell script to run. It can be used to start various applications you want to associate with starting X, e.g. the X screensaver, and to set global environment variables, like MOZ_PLUGIN_PATH. It's foremost use however, is

The .xinitrc file is really just one more shell script to run. It can be used to start various applications you want to associate with starting X, e.g. the X screensaver, and to set global environment variables, like MOZ_PLUGIN_PATH. It's foremost use however, is

−

as a replacement for a display manager when on a single user machine. When you do not start a display manager it is important to keep in mind that the life of your X session starts and ends with the .xinitrc script. What this means is that once the script finishes, X quits, regardless of whether you still have running programs, including your window manager. It is therefore important that the window manager quitting and X quitting should coincide. This is usually achieved by running the window manager as the last thing in the .xinitrc script, e.g.

+

as a replacement for a [[display manager]] when on a single user machine. When you do not start a display manager it is important to keep in mind that the life of your X session starts and ends with the .xinitrc script. What this means is that once the script finishes, X quits, regardless of whether you still have running programs, including your window manager. It is therefore important that the window manager quitting and X quitting should coincide. This is usually achieved by running the window manager as the last thing in the .xinitrc script, e.g.

/usr/bin/xscreensaver -no-splash &

/usr/bin/xscreensaver -no-splash &

Revision as of 09:30, 29 September 2008

The xinit program is used to start the X Window System server and a first client program on systems that cannot start X directly from /etc/init or in environments that use multiple window systems. The .xinitrc file is therefore a simple way to start x usually in conjunction with running the startx script directly from inittab.

Contents

How it works

The .xinitrc file is really just one more shell script to run. It can be used to start various applications you want to associate with starting X, e.g. the X screensaver, and to set global environment variables, like MOZ_PLUGIN_PATH. It's foremost use however, is
as a replacement for a display manager when on a single user machine. When you do not start a display manager it is important to keep in mind that the life of your X session starts and ends with the .xinitrc script. What this means is that once the script finishes, X quits, regardless of whether you still have running programs, including your window manager. It is therefore important that the window manager quitting and X quitting should coincide. This is usually achieved by running the window manager as the last thing in the .xinitrc script, e.g.

Notice that the screensaver and the notification daemon are run in the background. Otherwise the script would halt and wait for the screensaver program to quit before continuing. The line starting Openbox, however is not backgrounded. This ensures that the script will not quit until Openbox does.

A standard .xinitrc

Using this template you can simply uncomment your favourite, e.g. Gnome

Multiple DE options

On the command line

If you have a working .xinitrc, but just want to try other WM/DE you can run xinit from command line like this

xinit /full/path/to/window-manager

The full path is required. Optionally you can pass options to X server after '--', e.g.

xinit /usr/bin/enlightenment -- -br +bs -dpi 96

At startup

You can also have a choice of window managers and desktop environments at startup, using just .xinitrc and GRUB and no display manager. The idea is to take advantage of the fact that Arch doesn't make any particular use of the runlevel system. The following .xinitrc tests for the current runlevel and will start Openbox and GNOME on runlevels 5 and 4 respectively:

Choosing between different runlevels is simply a matter of cloning a GRUB entry and adding the desired runlevel to the kernel arguments. Inserting the runlevel at the end of the 'kernel' line indicates that the inittab's default of runleve 5 should be overridden and replaced with the desired runlevel, 4 in this instance:

Finally, you will need to ensure that the .xinitrc file is actually run at the chosen runlevel. Using the tip from the startx article, you can edit the inittab to simply run startx on the desired runlevel which will in turn use your .xinitrc script:

Notice that "45" means that this will happen on both runlevels 4 and 5. The final differentiation between 4 and 5 will then come in .xinitrc as described above. This is preferable to attempt differentiating in the inittab file as we stick pretty close to using the various configuration files as they were intended.