Starting a Window Manager

When the idea of a graphical system for Unix was first introduced, there was a basic (very basic) graphical screen, based on what some of you will recognise as <I>xdm</I>. That is all well and good, but for those of us that like the CLI (Command-Line Interface), you can use:

startx

to force a normal console-login to start your desired window-manager. Graphical login managers use the underlying configuration file:

~/.xsession

While startx uses:

~/.xinitrc

Although, if no ~/.xinitrc file is present, startx will read ~/.xsession quite happily.

Initially (unless you have added one to /etc/skel/), these files won't exist. That's OK, we'll create them:

touch ~/.xsession ~/.xinitrc && chmod 700 ~/.xsession ~/.xinitrc

The contents of which could look something like:

   1 #!/bin/sh
   2 # to make things compatible as possible, from this
   3 # .xsession file you may also read .xinitrc if it exists
   4 #[ -e $HOME/.xinitrc ] && source $HOME/.xinitrc
   5 
   6 export WINDOW_MANAGER=$(which fvwm-themes-start)
   7 
   8 #Add any other applications that you want started 
   9 #along with the window manager here, in the form:
  10 #
  11 xscreensaver &
  12 fbpanel &
  13 some_other_program &
  14 
  15 # Start the window manager.
  16 exec $WINDOW_MANAGER

Obviously, one would replace 'fvwm-themes-start' with their preferred window manager or desktop environment. If you're using gnome then'll you'll want to launch 'gnome-session'. If you're using KDE, then you'll want to launch 'startkde'.

Some people like to symlink ~/.xinitrc to ~/.xsession and vice-versa. I personally suggest to keep ~/.xinitrc separate from ~/.xsession since it is useful for recovery purposes to X11.

That's it. :)

LinuxHints/StartX (last edited 2010-10-09 09:31:29 by 232-204)