Hack 19. Get Multiple Desktops the Macho Way


stinkin' graphical login managers, so
here's the command-line way.This hack assumes you're not the type
who
likes to have graphical login screens running all the time. You want
your computer to boot to a text login prompt, after which
you're perfectly capable of getting a graphical
desktop running. You might still want the ability to have a second
person log in and start another desktop. So, here's
how.I'll assume you're the power user
who avoids GDM, KDM, and XDM. When your computer finishes booting, it
leaves you in a virtual console (virtual terminal 1) with a text
login prompt. You log in, and then you start your favorite window
manager or desktop using whatever command is most familiar to you.
Perhaps you type startkde to start the KDE
environment. You could type xinit
/usr/bin/wmaker to start WindowMaker. You could
also type startx alone to start your default
window manager. The default window manager could be defined in
various ways, depending on the Linux distribution
you're using. In most cases, power users configure
the ~/.xinitrc file to define the default window
manager, among other things (~/.xinitrc also
lets you define other programs to start automatically, etc.).If you want another user, such as your power-user daughter, to log in
and start up a separate desktop, press Ctrl-Alt-F2 to get to the
second text console with a login prompt. When she logs in, she can
start a new WindowMaker desktop without disturbing your desktop by
typing either of the following two commands:
$In this case, you add a space, a double-dash followed by a space,
xinit /usr/bin/wmaker -- :1
$ startx /usr/bin/wmaker -- :1
then a colon, and then a 1. This tells your system to run WindowMaker
on the second virtual console allocated for graphical desktops (the
default is 0, so the next available graphical console is 1).This is a rather inconvenient way to do things because you must be
sure display 1 is not in use, and you must know the exact path to the
window manager or desktop environment you want to start. Neither of
the following simpler commands works, because they do not include the
full path to the executables:
$ xinit wmaker -- :1The following script makes this whole process much easier. All you
$ startx wmaker -- :1
need to know is the name of the executable file that starts your
preferred window manager or desktop. Log in as root, or use
sudo to fire up your favorite text editor, and
type in the following script:
#!/bin/bashSave it as /usr/local/bin/mstartx. (I used the
screen=nothing
for screen in 0 1 2 3 4 5 nomore
do
if [ "$screen" = "nomore" ]
then
echo "No more available screens."
exit 1
fi
[ ! -e /tmp/.X${screen}-lock ] && break
done
if [ -x "`which ${1} 2>/dev/null`" ]
then
windowmanager="`which ${1} 2>/dev/null`"
echo $windowmanager
xinit $windowmanager -- -br :$screen
else
xinit -- -br :$screen
fi
name mstartx because it is short for
multiple-startx, but you can name your script
anything you want.) Then change the script to be executable with this
command:
# chmod +x /usr/local/bin/mstartxNow all you have to type to start WindowMaker is this:
# mstartx wmakerThe script performs two important tasks. First, it finds the first
available graphical console. If two people are already using
graphical desktops, the script will detect this and automatically run
the next session on the third graphical desktop. Second, it
automatically locates the full path to the executable file for the
window manager you want to start
(/usr/bin/wmaker in this example). As an added
bonus, this script changes the default startup background from a gray
mesh to solid black. [Hack #22]
provides an alternate way to blacken your startup background.Table 3-1 lists the executable filenames for the
most popular window managers.
Window manager or desktop environment | Executable filename |
---|---|
KDE | Startkde |
GNOME | gnome-session |
WindowMaker | Wmaker |
AfterStep | Afterstep |
XFce 4 | Startxfce4 |
IceWM | Icewm |
Enlightenment | Enlightenment |
qvwm | Qvwm |
Fluxbox | fluxbox or startfluxbox |
Blackbox | Blackbox |
Openbox | Openbox |
Fvwm | fvwm or fvwm2 |
XFce 3 | Xfce |
Motif | Mwm |
|