NetBSD Documentation: The X Window System
NotePlease see the NetBSD Guide's chapter on X for more information about X.
- How do I make the Caps key another Control key
- How to bypass xdm
- When I type 'startx' I get the message: startx: Command not found. What's wrong?
- Unable to run X - 'xinit: not found'
- startx fails -'X connection to: 0.0 broken'
- Console output (such as from 'su') garbles X display.
- XFree86 Documentation
- Which version of XFree86 am I running?
- How to setup anti-aliased fonts on NetBSD for X11
- Xft using applications eat CPU cycles, but don't appear to do anything!
- 'No fonts found' - what does this mean?
- How do I change the default window manager?
- Compile fails - 'unable to locate libXm'
- Compile fails - 'unable to locate xpm.h', or '-lXpm: no match'
- Compile fails to link: Undefined symbol '_XOpenDisplay'
How do I make the Caps key another Control key (top)
For XFree 3.x (as shipped with NetBSD 1.l5), add
XkbOptions "ctrl:nocaps"” if you
want the caps-lock key become a second control-key. If you
want to use the "Windows" keys on your keyboard, you can get
some useful keysyms for them by using
XkbModel "pc105"” instead.
XFree 4.x uses a different config file format. For it, put
Option "XkbOptions" "ctrl:nocaps"
into the "InputDevice" section of your XF86Config file.
How to bypass xdm (top)
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
ENTERwhen prompted for the shell.
- Check and mount the disks using fsck(8) and
fsck -p ; mount -vat ffs
- Set term terminal type -
TERM=vt100 ; export TERMNote: you may need to use a different terminal type such as 'pc3' or 'sun'.
- Fix problem - Edit
/etc/rc.confto disable xdm, run passwd(1) to set root's password, or take whatever other corrective action is needed
When I type '
startx' I get the message:
startx: Command not found. What's wrong? (top)
You need to add the location of the X binaries to your
path variable. For csh(1) and its
to the line in your
.cshrc file which
path variable. For
its derivatives, you'll need to modify you
Unable to run X - 'xinit: not found' (top)
/usr/X11R6/bin in your
path. As root add '
set path = ( $path /usr/X11R6/bin )'
/etc/csh.cshrc, and start a new
startx fails -'X connection to: 0.0 broken' (top)
To see the error messages in this case, run:
Console output (such as from 'su') garbles X display. (top)
The system is outputting a line to the console indicating something has happened (such as 'su'). You should really run xconsole(1) or one 'xterm -C' to capture this console output.
You may need to ensure your kernel is compiled with the following enabled:
options UCONSOLE # allow anyone to steal the virtual console
See How to build a kernel for details on how to build your own kernels.
If you're logged in as root, and get annoying
portmap notices, you may wish to look at the
on how to turn those messages off.
Which version of XFree86 am I running? (top)
To quickly tell which version of the X server you are running, you can use xdpyinfo(1). E.g.:
$ xdpyinfo | grep release vendor release number: 335
In the case of XFree86, this tells us that the server version is 3.3.5.
How to setup anti-aliased fonts on NetBSD for X11 (top)
The paths below should be adjusted appropriately if using
If using the XFree86 shipped with NetBSD, you may consider using
fonts/fontconfigfrom pkgsrc as it offers more tweaking options. Set the variable
PREFER.fontconfigto pkgsrc in the
/etc/mk.conffile to ensure that the pkgsrc version is used in favour of the shipped (or native) version:
You may also want to instruct fontconfig to never use bitmap fonts again:
# cd /usr/pkg/etc/fontconfig/conf.d # ln -s ../../../share/examples/fontconfig/conf.avail/70-no-bitmaps.conf .
You may wish to replace the native fontconfig libraries entirely, which is useful should you have any previously-compiled binaries that used it.
# cd /usr/X11R6/lib # mv libfontconfig.so.1.0 libfontconfig.so.1.0.old # rm libfontconfig.so.1 # ln -s ../../pkg/lib/libfontconfig.so.1 . # cd /usr/X11R6/bin # mv fc-cache fc-cache.old # mv fc-list fc-list.old
To configure fontconfig, add the following line to your local.conf. This file is generally found in
/etc/fonts/local.conf. If you installed the fonts/fontconfig package, you will also need to add the line to
/usr/pkg/etc/fonts/local.conf(or replace one with a symbolic link to another):
local.conffile may look like this:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>/usr/pkg/lib/X11/fonts/TTF</dir> </fontconfig>
You can also add other directories containing fonts to the
local.conffile. The following lines are for using teTeX-3.0 and ghostscript fonts:
Rebuild the font cache for applications that use fontconfig
# fc-cache -v
Depending on your hardware this may take a long time.
Run the following commands:
# mkfontscale /usr/pkg/lib/X11/fonts/TTF # mkfontdir /usr/pkg/lib/X11/fonts/TTF
There should now be the files
fonts.scalein the TTF font directory.
Configure the X server:
In the “Module” section, make sure that the following exists:
Load "type1" Load "freetype"
In the “Files” section, verify the order of the font paths. Verify that the TTF and Type1 font paths are before the rest:
FontPath "/usr/X11R6/lib/X11/fonts/local/" FontPath "/usr/pkg/lib/X11/fonts/TTF" FontPath "/usr/X11R6/lib/X11/fonts/Type1/" FontPath "/usr/X11R6/lib/X11/fonts/misc/" FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/75dpi/" FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
To apply the changes to the current X session, instead of restarting X, run the following command
# xset fp rehash
This will examine newly added font paths for changes.
Instead of adding “FontPath” directives to the X configuration file, you can run the following commands from
xset +fp /usr/X11R6/lib/X11/fonts/Type1 xset +fp /usr/pkg/lib/X11/fonts/TTF xset +fp /usr/X11R6/lib/X11/fonts/local
That's it! Run the following commands to test the configuration.
$ xterm -ls -fg gray -bg black -ls -fa 'Courier New:bold' -fs 10
Run the command
fc-listit should list the fonts available, and shouldn't dump core!
While the xterm command from above only tests the fontconfig part, the following command will test the XLFD-style access:
$ xterm -fn '-monotype-Courier New-medium-r-normal--0-0-0-0-m-0-iso8859-1'
Another test is that the following should show multiple fonts:
$ xlsfonts | grep -i 'courier new'
You can find other TTF font packages under pkgsrc/fonts. For example
Xft using applications eat CPU cycles, but don't appear to do anything! (top)
It is possible that the application in question is
computing the font information that should have been
prepared by fc-cache - re-run '
fc-cache -v' to
make sure the information in the cache is up-to-date.
'No fonts found' - what does this mean? (top)
No fonts found; this probably means that the fontconfig library is not correctly configured. You may need to edit the fonts.conf configuration file. More information about fontconfig can be found in the fontconfig(3) manual page and on http://fontconfig.org
How do I change the default window manager? (top)
First thing to do is to install the window manager you
prefer. You can find a lot of them, ready to install, in
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 twm in our examples (which comes with X), whose binary
You can see that the content for each file is the same, so you may want to create a link between them.
Compile fails - 'unable to locate libXm' (top)
Xm does not come with the standard X11 environment. It is part of Motif, which is a commercial graphical user interface.
Compile fails - 'unable to locate xpm.h', or '-lXpm: no match' (top)
Compile fails to link: Undefined symbol '_XOpenDisplay' (top)
If it is a third party item of software, you should
check if a version is available via the NetBSD packages collection.
If you are writing you own code you need to ensure you link
against the necessary X libraries. In this case, add
-L/usr/X11R6 -lX11 to the end of your link
Back to NetBSD Documentation