Archive

Start X

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 xdm. 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:

#!/bin/sh 
# to make things compatible as possible, from this 
# .xsession file you may also read .xinitrc if it exists
# [ -e $HOME/.xinitrc ] && source $HOME/.xinitrc

export WINDOW_MANAGER=$(which fvwm-themes-start)
 
#Add any other applications that you want started
#along with the window manager here, in the form:
#
xscreensaver & 
fbpanel & 
some_other_program &
  
# Start the window manager.
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. :)

Leave a Reply