NetBSD Documentation: The X Window System

Note

Please see the NetBSD Guide's chapter on X for more information about X.

Running X

Compiling programs


Running X

How to make the Caps Lock key another Control key

Many Unix key bindings are designed around this layout, because it was traditional on older terminals until the standard layout was changed by IBM.

Add the following to your ~/.xsession or ~/.xinitrc:

setxkbmap -layout us -option ctrl:swapcaps

You can also disable Caps Lock entirely:

setxkbmap -layout us -option ctrl:nocaps

Many other layout options are available, see /usr/X11R7/lib/X11/xkb/rules/base.lst.

How to bypass xdm

If xdm(1) is enabled but you are unable to login for some reason, possibly because there is no root password, and you do not have virtual consoles enabled (or they are not yet supported on your port), you can either press ^C at the immediately after the boot messages indicate xdm is starting, or:

  • Boot to single user mode - Usually this is accomplished by passing '-s' at the end of the boot command.
  • Start the shell - Press ENTER when prompted for the shell.
  • Check and mount the disks using fsck(8) and mount(8) - fsck -p ; mount -vat ffs
  • Set term terminal type - TERM=vt100 ; export TERM Note: you may need to use a different terminal type such as 'pc3' or 'sun'.
  • Fix problem - Edit /etc/rc.conf to disable xdm, run passwd(1) to set root's password, or take whatever other corrective action is needed

startx: not found

If the X sets are installed but no X commands work, you need to add the location of the X binaries (/usr/X11R7/bin) to your shell's PATH variable. For sh(1) and its derivatives, you'll need to modify your ~/.profile. For csh(1) and its derivatives, add to the line in your .cshrc file which sets the path.

startx fails -'X connection to: 0.0 broken'

To see the error messages in this case, run:

Then, view ~/x.log.

How do I change the default window manager?

First thing to do is to install the window manager you prefer. You can find a lot of them, ready to install, in pkgsrc's wm category. After a successful installation, figure out how is the binary named. It will usually match package's name.

Once you know how to execute the window manager, you have to configure your X session to start it up. We will be using ctwm in our examples (which comes with X), whose binary is named ctwm:

  • If you are using startx(1), edit the ~/.xinitrc file and append the following line to it: exec ctwm
  • If you are using xdm(1), edit the ~/.xsession file and append the following line to it: exec ctwm

You can see that the content for each file is the same, so you may want to create a link between them.


Compiling programs

Program fails to link: cannot find -lX11

If it is a third party item of software, you should check if a version is available via the NetBSD packages collection. Otherwise, you need to ensure the linker flags (or LDFLAGS) contain -L/usr/X11R7/lib, -Wl,-R/usr/X11R7/lib.


Back to NetBSD Documentation