Frequently Asked Questions for FreeBSD 6.`X`, 7.`X` and 8.`X`
Prev |  | Next

# Chapter 11 The X Window System and Virtual Consoles

11.1. What is the X Window System?
11.2. Which X implementations are available for FreeBSD?
11.3. Why did the X projects split, anyway?
11.4. Why did FreeBSD choose to go with the Xorg ports by default?
11.5. I want to run X, how do I go about it?
11.6. I tried to run X, but I get an “`KDENABIO failed (Operation not permitted)`” error when I type `startx`. What do I do now?
11.7. Why does my mouse not work with X?
11.8. My mouse has a fancy wheel. Can I use it in X?
11.9. How do I use remote X displays?
11.10. What is a virtual console and how do I make more?
11.11. How do I access the virtual consoles from X?
11.12. How do I start XDM on boot?
11.13. Why do I get “`Couldn't open console`” when I run `xconsole`?
11.14. Before, I was able to run XFree86 as a regular user. Why does it now say that I must be `root`?
11.15. Why does my PS/2 mouse misbehave under X?
11.16. Why does my PS/2 mouse from MouseSystems not work?
11.17. How do I reverse the mouse buttons?
11.18. How do I install a splash screen and where do I find them?
11.19. Can I use the Windows keys on my keyboard in X?
11.20. How can I get 3D hardware acceleration for OpenGL®?

11.1. What is the X Window System?

The X Window System (commonly `X11`) is the most widely available windowing system capable of running on UNIX® or UNIX like systems, including FreeBSD. The X.Org Foundation administers the X protocol standards, with the current reference implementation, version 11 release 7.5, so you will often see references shortened to `X11`.

Many implementations are available for different architectures and operating systems. An implementation of the server-side code is properly known as an `X server`.

11.2. Which X implementations are available for FreeBSD?

Historically, the default implementation of X on FreeBSD has been XFree86™ which is maintained by The XFree86 Project, Inc. This software was installed by default on FreeBSD versions up until 4.10 and 5.2. Although Xorg itself maintained an implementation during that time period, it was basically only provided as a reference platform, as it had suffered greatly from bitrot over the years.

However, early in 2004, some XFree86 developers left that project over issues including the pace of code changes, future directions, and interpersonal conflicts, and are now contributing code directly to Xorg instead. At that time, Xorg updated its source tree to the last XFree86 release before its subsequent licensing change (XFree86 version 4.3.99.903), incorporated many changes that had previously been maintained separately, and has released that software as X11R6.7.0. A separate but related project, freedesktop.org (or `fd.o` for short), is working on rearchitecting the original XFree86 code to offload more work onto the graphics cards (with the goal of increased performance) and make it more modular (with the goal of increased maintainability, and thus faster releases as well as easier configuration). Xorg intends to incorporate the `freedesktop.org` changes in its future releases.

As of July 2004, in FreeBSD-CURRENT, XFree86 has been replaced with Xorg as the default implementation. Since then the default X11 implementation in FreeBSD is Xorg.

For further information, read the X11 section of the FreeBSD Handbook.

11.3. Why did the X projects split, anyway?

The answer to this question is outside the scope of this FAQ. Note that there are voluminous postings in various mailing list archives on the Internet; please use your favorite search engine to investigate the history instead of asking this question on the FreeBSD mailing lists. It may even be the case that only the participants will ever know for certain.

11.4. Why did FreeBSD choose to go with the Xorg ports by default?

The Xorg developers claimed that their goal is to release more often and incorporate new features more quickly. If they are able to do so, this will be very attractive. Also, their software still uses the traditional X license, while XFree86 is using their modified one.

11.5. I want to run X, how do I go about it?

If you would like to add X to an existing installation, you should use either the `x11/xorg` meta-port, which will build and install all the necessary components, or install Xorg from FreeBSD packages:

    # pkg_add -r xorg

It is also possible to install Xorg from sysinstall(8) by choosing Configure, then Distributions, then The X.Org Distribution.

After the installation of Xorg was successful, follow the instructions from the X11 Configuration section of the FreeBSD Handbook.

11.6. I tried to run X, but I get an “`KDENABIO failed (Operation not permitted)`” error when I type `startx`. What do I do now?

Your system is probably running at a raised `securelevel`. It is not possible to start X at a raised `securelevel` because X requires write access to io(4). For more information, see at the init(8) manual page.

So the question is what else you should do instead, and you basically have two choices: set your `securelevel` back down to zero (usually from `/etc/rc.conf`), or run xdm(1) at boot time (before the `securelevel` is raised).

See Q: 11.12. for more information about running xdm(1) at boot time.

11.7. Why does my mouse not work with X?

If you are using syscons(4) (the default console driver), you can configure FreeBSD to support a mouse pointer on each virtual screen. In order to avoid conflicting with X, syscons(4) supports a virtual device called `/dev/sysmouse`. All mouse events received from the real mouse device are written to the sysmouse(4) device via moused(8). If you wish to use your mouse on one or more virtual consoles, and use X, see Q: 4.5.4. and set up moused(8).

Then edit `/etc/X11/xorg.conf` and make sure you have the following lines:

    Section "InputDevice"
       Option          "Protocol" "SysMouse"
       Option          "Device" "/dev/sysmouse"
    .....

Starting with Xorg version 7.4, the `InputDevice` sections in `xorg.conf` are ignored in favor of autodetected devices. To restore the old behavior, add the following line to the `ServerLayout` or `ServerFlags` section:

    Option "AutoAddDevices" "false"

Some people prefer to use `/dev/mouse` under X. To make this work, `/dev/mouse` should be linked to `/dev/sysmouse` (see sysmouse(4)) by adding the following line to `/etc/devfs.conf` (see devfs.conf(5)):

    link    sysmouse    mouse

This link can be created by restarting devfs(5) with the following command (as `root`):

    # /etc/rc.d/devfs restart

11.8. My mouse has a fancy wheel. Can I use it in X?

Yes.

You need to tell X that you have a 5 button mouse. To do this, simply add the lines `Buttons 5` and `ZAxisMapping 4 5` to the “InputDevice” section of `/etc/X11/xorg.conf`. For example, you might have the following “InputDevice” section in `/etc/X11/xorg.conf`.

Example 11-1. “InputDevice” Section for Wheeled Mouse in Xorg Configuration File

    Section "InputDevice"
       Identifier      "Mouse1"
       Driver          "mouse"
       Option          "Protocol" "auto"
       Option          "Device" "/dev/sysmouse"
       Option          "Buttons" "5"
       Option          "ZAxisMapping" "4 5"
    EndSection

Example 11-2. “.emacs” Example for Naive Page Scrolling with Wheeled Mouse (optional)

    ;; wheel mouse
    (global-set-key [mouse-4] 'scroll-down)
    (global-set-key [mouse-5] 'scroll-up)

11.9. How do I use remote X displays?

For security reasons, the default setting is to not allow a machine to remotely open a window.

To enable this feature, simply start X with the optional `-listen_tcp` argument:

    % startx -listen_tcp

11.10. What is a virtual console and how do I make more?

Virtual consoles, put simply, enable you to have several simultaneous sessions on the same machine without doing anything complicated like setting up a network or running X.

When the system starts, it will display a login prompt on the monitor after displaying all the boot messages. You can then type in your login name and password and start working (or playing!) on the first virtual console.

At some point, you will probably wish to start another session, perhaps to look at documentation for a program you are running or to read your mail while waiting for an FTP transfer to finish. Just do Alt+F2 (hold down the Alt key and press the F2 key), and you will find a login prompt waiting for you on the second “virtual console”! When you want to go back to the original session, do Alt+F1.

The default FreeBSD installation has eight virtual consoles enabled. Alt+F1, Alt+F2, Alt+F3, and so on will switch between these virtual consoles.

To enable more of them, edit `/etc/ttys` (see ttys(5)) and add entries for `ttyv8` to `ttyvc` after the comment on “Virtual terminals”:

    # Edit the existing entry for ttyv8 in /etc/ttys and change
    # "off" to "on".
    ttyv8   "/usr/libexec/getty Pc"         cons25  on secure
    ttyv9   "/usr/libexec/getty Pc"         cons25  on secure
    ttyva   "/usr/libexec/getty Pc"         cons25  on secure
    ttyvb   "/usr/libexec/getty Pc"         cons25  on secure

Use as many or as few as you want. The more virtual terminals you have, the more resources that are used; this can be important if you have 8 MB RAM or less. You may also want to change the `secure` to `insecure`.

> Important: If you want to run an X server you must leave at least one virtual terminal unused (or turned off) for it to use. That is to say that if you want to have a login prompt pop up for all twelve of your Alt-function keys, you are out of luck -- you can only do this for eleven of them if you also want to run an X server on the same machine.

The easiest way to disable a console is by turning it off. For example, if you had the full 12 terminal allocation mentioned above and you wanted to run X, you would change settings for virtual terminal 12 from:

    ttyvb   "/usr/libexec/getty Pc"         cons25  on  secure

to:

    ttyvb   "/usr/libexec/getty Pc"         cons25  off secure

If your keyboard has only ten function keys, you would end up with:

    ttyv9   "/usr/libexec/getty Pc"         cons25  off secure
    ttyva   "/usr/libexec/getty Pc"         cons25  off secure
    ttyvb   "/usr/libexec/getty Pc"         cons25  off secure

(You could also just delete these lines.)

Next, the easiest (and cleanest) way to activate the virtual consoles is to reboot. However, if you really do not want to reboot, you can just shut down the X Window system and execute (as `root`):

    # kill -HUP 1

It is imperative that you completely shut down X Window if it is running, before running this command. If you do not, your system will probably appear to hang or lock up after executing the `kill` command.

11.11. How do I access the virtual consoles from X?

Use Ctrl+Alt+F`n` to switch back to a virtual console. Ctrl+Alt+F1 would return you to the first virtual console.

Once you are back to a text console, you can then use Alt+F`n` as normal to move between them.

To return to the X session, you must switch to the virtual console running X. If you invoked X from the command line, (e.g., using `startx`) then the X session will attach to the next unused virtual console, not the text console from which it was invoked. If you have eight active virtual terminals then X will be running on the ninth, and you would use Alt+F9 to return.

11.12. How do I start XDM on boot?

There are two schools of thought on how to start xdm(1). One school starts `xdm` from `/etc/ttys` (see ttys(5)) using the supplied example, while the other simply runs `xdm` from from `rc.local` (see rc(8)) or from an `X` script in `/usr/local/etc/rc.d`. Both are equally valid, and one may work in situations where the other does not. In both cases the result is the same: X will pop up a graphical login prompt.

The ttys(5) method has the advantage of documenting which vty X will start on and passing the responsibility of restarting the X server on logout to init(8). The rc(8) method makes it easy to `kill` `xdm` if there is a problem starting the X server.

If loaded from rc(8), `xdm` should be started without any arguments (i.e., as a daemon). The `xdm` command must start after getty(8) runs, or else `getty` and `xdm` will conflict, locking out the console. The best way around this is to have the script sleep 10 seconds or so then launch `xdm`.

If you are to start `xdm` from `/etc/ttys`, there still is a chance of conflict between `xdm` and getty(8). One way to avoid this is to add the `vt` number in the `/usr/local/lib/X11/xdm/Xservers` file:

    :0 local /usr/local/bin/X vt4

The above example will direct the X server to run in `/dev/ttyv3`. Note the number is offset by one. The X server counts the vty from one, whereas the FreeBSD kernel numbers the vty from zero.

11.13. Why do I get “`Couldn't open console`” when I run `xconsole`?

If you start X with `startx`, the permissions on `/dev/console` will not get changed, resulting in things like `xterm -C` and `xconsole` not working.

This is because of the way console permissions are set by default. On a multi-user system, one does not necessarily want just any user to be able to write on the system console. For users who are logging directly onto a machine with a VTY, the fbtab(5) file exists to solve such problems.

In a nutshell, make sure an uncommented line of the form is in `/etc/fbtab` (see fbtab(5)):

    /dev/ttyv0 0600 /dev/console

It will ensure that whomever logs in on `/dev/ttyv0` will own the console.

11.14. Before, I was able to run XFree86 as a regular user. Why does it now say that I must be `root`?

All X servers need to be run as `root` in order to get direct access to your video hardware. Older versions of XFree86 (<= 3.3.6) installed all bundled servers to be automatically run as `root` (setuid to `root`). This is obviously a security hazard because X servers are large, complicated programs. Newer versions of XFree86 do not install the servers setuid to `root` for just this reason.

Obviously, running an X server as the `root` user is not acceptable, nor a good idea security-wise. There are two ways to be able to use X as a regular user. The first is to use `xdm` or another display manager (e.g., `kdm`); the second is to use the `Xwrapper`.

`xdm` is a daemon that handles graphical logins. It is usually started at boot time, and is responsible for authenticating users and starting their sessions; it is essentially the graphical counterpart of getty(8) and login(1). For more information on `xdm` see the XFree86 documentation, and the the FAQ entry on it.

`Xwrapper` is the X server wrapper; it is a small utility to enable one to manually run an X server while maintaining reasonable safety. It performs some sanity checks on the command line arguments given, and if they pass, runs the appropriate X server. If you do not want to run a display manager for whatever reason, this is for you. If you have installed the complete Ports Collection, you can find the port in `x11/wrapper`.

11.15. Why does my PS/2 mouse misbehave under X?

Your mouse and the mouse driver may have somewhat become out of synchronization.

In rare cases the driver may erroneously report synchronization problem and you may see the kernel message:

    psmintr: out of sync (xxxx != yyyy)

and notice that your mouse does not work properly.

If this happens, disable the synchronization check code by setting the driver flags for the PS/2 mouse driver to `0x100`. Enter UserConfig by giving the `-c` option at the boot prompt:

    boot: -c

Then, in the UserConfig command line, type:

    UserConfig> flags psm0 0x100
    UserConfig> quit

11.16. Why does my PS/2 mouse from MouseSystems not work?

There have been some reports that certain model of PS/2 mouse from MouseSystems works only if it is put into the “high resolution” mode. Otherwise, the mouse cursor may jump to the upper-left corner of the screen every so often.

Specify the flags `0x04` to the PS/2 mouse driver to put the mouse into the high resolution mode. Enter UserConfig by giving the `-c` option at the boot prompt:

    boot: -c

Then, in the UserConfig command line, type:

    UserConfig> flags psm0 0x04
    UserConfig> quit

See the previous section for another possible cause of mouse problems.

11.17. How do I reverse the mouse buttons?

Run the command `xmodmap -e "pointer = 3 2 1"` from your `.xinitrc` or `.xsession`.

11.18. How do I install a splash screen and where do I find them?

The detailed answer for this question can be found in the Boot Time Splash Screens section of the FreeBSD Handbook.

11.19. Can I use the Windows keys on my keyboard in X?

Yes. All you need to do is use xmodmap(1) to define what function you wish them to perform.

Assuming all “Windows” keyboards are standard then the keycodes for these three keys are the following:

- 115 -- Windows key, between the left-hand Ctrl and Alt keys

- 116 -- Windows key, to the right of the AltGr key

- 117 -- Menu key, to the left of the right-hand Ctrl key

To have the left Windows key print a comma, try this.

    # xmodmap -e "keycode 115 = comma"

You will probably have to re-start your window manager to see the result.

To have the Windows key-mappings enabled automatically every time you start X either put the `xmodmap` commands in your `~/.xinitrc` file or, preferably, create a file `~/.xmodmaprc` and include the `xmodmap` options, one per line, then add the following line to your `~/.xinitrc`:

    xmodmap $HOME/.xmodmaprc

For example, you could map the 3 keys to be F13, F14, and F15, respectively. This would make it easy to map them to useful functions within applications or your window manager, as demonstrated further down.

To do this put the following in `~/.xmodmaprc`.

    keycode 115 = F13
    keycode 116 = F14
    keycode 117 = F15

If you use the `x11-wm/fvwm2` port, for example, you could map the keys so that F13 iconifies (or de-iconifies) the window the cursor is in, F14 brings the window the cursor is in to the front or, if it is already at the front, pushes it to the back, and F15 pops up the main Workplace (application) menu even if the cursor is not on the desktop, which is useful if you do not have any part of the desktop visible (and the logo on the key matches its functionality).

The following entries in `~/.fvwmrc` implement the aforementioned setup:

    Key F13        FTIWS    A        Iconify
    Key F14        FTIWS    A        RaiseLower
    Key F15        A        A        Menu Workplace Nop

11.20. How can I get 3D hardware acceleration for OpenGL®?

The availability of 3D acceleration depends on the version of Xorg that you are using and the type of video chip you have. If you have an nVidia chip, you can use the binary drivers provided for FreeBSD by installing one of the following ports:

- The latest versions of nVidia cards are supported by the `x11/nvidia-driver` port.

- nVidia cards like the GeForce2 MX/3/4 series are supported by the 96XX series of drivers, available in the `x11/nvidia-driver-96xx` port.

- Even older cards, like GeForce and RIVA TNT are supported by the 71XX series of drivers, available in the `x11/nvidia-driver-71xx` port.

In fact, nVidia provides detailed information on which card is supported by which driver. This information is available directly on their web site: http://www.nvidia.com/object/IO_32667.html.

For Matrox G200/G400, you should check the `x11-servers/mga_hal` port.

For ATI Rage 128 and Radeon, see the ati(4), r128(4) and radeon(4) manual pages.

For 3dfx Voodoo 3, 4, 5, and Banshee cards, there is a `x11-servers/driglide` port.

Prev | Home | Next
System Administration |  | Networking