Peter's X Q&A

  1. How can I tell which server X is using?
  2. How do I remap the keyboard?
  3. How do I change my Window Manager?
  4. Is there a way I can get my computer to boot straight into X-Windows?
  5. How can I automatically have the number lock turned on when I boot X?
  6. How can I run X applications remotely?

  1. How can I tell which server X is using?
    Finding the file named X is the key to answering this question; it's usually a symlink to the X server binary. For example, on Suse 6.2:
    % which X
    /usr/X11R6/bin/X
    % ls -l /usr/X11R6/bin/X
    lrwxrwxrwx 1 root root 16 Oct 11 1999 /usr/X11R6/bin/X -> /var/X11R6/bin/X*
    % ls -l /var/X11R6/bin/X
    lrwxrwxrwx 1 root root 24 Oct 11 1999 /var/X11R6/bin/X -> /usr/X11R6/bin/XF86_SVGA*
    See how that works? We found the symlink X and followed it to another symlink X which pointed to yet another symlink X which finally pointed to the SVGA server binary.

    Debian is a bit different. The file /etc/X11/Xserver is a text file which gives the location of the server binary and who can use it.

    % cat Xserver
    /usr/bin/X11/XF86_SVGA
    Console

    The first line in this file is the full pathname of the default X server.
    The second line shows who is allowed to run the X server:
    RootOnly
    Console (anyone whose controlling tty is on the console)
    Anybody



  2. How do I remap the keyboard?
    This is best described using an example. Suppose you want your backspace key to be a delete key. There are two steps to mapping backspace to delete.

    First, run xev, which will tell you the keycode for any key. Put the X cursor in the tester box and press the backspace key. You'll see something like:

    KeyRelease event, serial 24, synthetic NO, window 0x1c00001,
    root 0x26, subw 0x1c00002, time 3098665090, (31,41), root:(622,60),
    state 0x0, keycode 22 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 characters: "
    This reports my backspace key to be keycode 22 (yours may be different).

    The 2nd step is to actually do the mapping, which is done using xmodmap To perform the mapping, try:

    xmodmap -e "keycode 22 = Delete"
    You can use xmodmap -pk to see what the valid targets are besides Delete. There's lots of them, like F1 through F12, Home, Up, Left, Control_R, KP_Enter, Pause, Print, Meta_L (Meta is the Alt key), KP_Down, KP_Insert and many, many more.

    See man xmodmap for more details.



  3. How do I change my Window Manager?
    The first step is to pick a window manager that you like. Most people seem to like Window Maker and Afterstep. Personally, I use the very fancy and powerful Enlightenment (without GNOME). It has lots of eye candy! When I play games, I tend to use the sparse, reliable and fast twm. Here's a URL that will show you a cross section of several window managers, choose for yourself the one you want to use: http://www.plig.org/xwinman/.

    At this point, I assume that you've picked out a wm and are all hot and bothered to try it out. Most likely, all these window managers are already on your system, ready to be used. I won't go into installing them here.

    In your home directory, there might be a file called .wm_style. This file contains the name of the window manager that you want X to start up. If you want Afterstep, .wm_style should contain the string `AfterStep'. If you want Enlightenment, the file should contain the word "Enlightenment". You need to be a bit careful about what you specify in this file, since computers are very bad at interpreting Afterstep to mean AfterStep. Some effort is made to do this interpretation, but if you want to know for sure what the string is, look at the output of less .Xclients (from your home directory). Even if you don't know shell programming, you should be able to figure out what X expects as valid strings in .wm_style. Next, kill your xserver (ctl-alt-backspace) and restart it with startx. You should be staring at a new window manager!

    If you don't have .wm_style (like if you have Debian), you want to edit a file named $HOME/.xinitrc. First find the location of the window manager executable by using the which command. For example, if you type which enlightenment, the system should respond with (for example) /usr/bin/enlightenment. Then, in .xinitrc you'll want to have the single line

    exec /usr/bin/enlightenment
    and you should be all set to go.



  4. Is there a way I can get my computer to boot straight into X-Windows?
    Add the line
    start-xdm
    to the end of the file /etc/X11/config.



  5. How can I automatically have the number lock turned on when I boot X?
    This is quite sad. You can't do it without downloading numlockx from www.freshmeat.net. You'd think that such a basic operation would be built into X!



  6. How can I run X applications remotely?
    On your local machine, allow the remote machine access to the X server by:
    xhost +remote.host.edu
    Next, start an ssh session to the remote host:
    ssh -X -C -cblowfish remote.host.edu
    The -X option tells ssh to enables X11 forwarding. The -C option tells ssh to compress all the incoming/outgoing packetsl. If you're at ethernet speeds or higher, this can actually make things slower, but on DSL and T1's it's supposed to help a lot (you may want to experiment with this).

    By default, ssh uses the 3des (triple DES) cipher scheme to encrypt the connection. By specifying -cblowfish, you're telling ssh to use the blowfish algorithm, which is appears to be equally as secure, but MUCH faster than 3des.

    If you get denied X11 forwarding then you'll need to allow X forwarding in the remote host's /etc/sshd/sshd.conf. If either the local or remote machines have a restrictive hosts.allow and/or hosts.deny, you'll have to add an entry for X-forwarding. Check out the man pages.

    This should all work if you're on a masqueraded machine going out onto the internet. If you're on the internet and want to run an application on a machine which is masqueraded behind a firewall, the firewall will need to have a hole to make things work. Lastly, look into lbx, low bandwidth X.

    Now all that stuff is for ssh, which automatically sets up the needed variables for X11 forwarding. If you use telnet (shame on you), you'll still need to use xhost (see above), but you'll have to manually set the $DISPLAY variable on the remote machine.

    export DISPLAY=local.host.edu:0 setenv DISPLAY local.host.edu:0
    for bash/sh and csh/tcsh shells.

    You can even make the local machine into an xterm for the remote machine. On the local machine, without X running, edit the appropriate starting script so it runs X with the following command:

    X -query remote.host.edu
    Now, when you start X, your local machine will appear to be an Xterm connected to the remote machine (with a little bit of a delay).

Please report bugs or broken links to me.