Difference between revisions of "Xinit"

From ArchWiki
Jump to: navigation, search
(Start file, '''~/.xinitrc''')
m (Starting different desktop environments HOWTO moved to .xinitrc: Seems appropriate as the article is really about the xinitrc file, a name that more people are likely to search for.)
(No difference)

Revision as of 08:37, 29 September 2008


Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

Summary

How to use startx command, to get x-server and your DE of choice running.

Start file, ~/.xinitrc

You start your DE from the file /home/yourname/.xinitrc Uncomment your favourite, eg Gnome

#!/bin/sh
#
# ~~/.xinitrc
#
# Executed by startx (run your window manager from here)
#
# exec ion
# exec wmaker
# exec startkde
# exec icewm
# exec blackbox
exec gnome-session
# exec startfluxbox
# exec startxfce4
# exec openbox
# exec startlxde


Small note: 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 -- Example:

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

Multiple DE options

You can 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:

rl=$(runlevel | grep -o [0-6])
case $rl in
	4) exec gnome-session;;
	5) exec openbox-session;;
esac

Choosing between different runlevel is simply a matter of adding the desired runlevel to the kernel arguments in a GRUB entry, like so:

title  Arch Linux GNOME
root   (hd0,2)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/a29113d7-2204-49e9-be69-d94699eba466 ro 4
initrd /boot/kernel26.img

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:

x:45:once:/bin/su PREFERED_USER -l -c "/bin/bash --login -c startx >/dev/null 2>&1"

Notice that "45" means that this will happen on both runlevels 4 and 5. The final differentiation 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.