NetBSD Documentation: The X Window System
Note
Please see the NetBSD Guide's chapter on X for more information about X.Running 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?
Compiling programs
- Compile fails - 'unable to locate libXm'
- Compile fails - 'unable to locate xpm.h', or '-lXpm: no match'
- Compile fails to link: Undefined symbol '_XOpenDisplay'
Running X
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
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
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
shell's path
variable. For csh(1) and its
derivatives, add /usr/X11R6/bin
to the line in your .cshrc
file which
sets the path
variable. For sh
and
its derivatives, you'll need to modify you
.profile
instead.
Unable to run X - 'xinit: not found' (top)
You need /usr/X11R6/bin
in your
path. As root add 'set path = ( $path /usr/X11R6/bin )
'
to /etc/csh.cshrc
, and start a new
shell.
startx fails -'X connection to: 0.0 broken' (top)
To see the error messages in this case, run:
- If your shell is csh(1) or
shells/tcsh
:startx >& ~/x.log
- If your shell is sh(1), ksh(1), or similar:
startx > ~/x.log 2>&1
Then view ~/x.log
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
FAQ entry
on how to turn those messages off.
XFree86 Documentation (top)
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)
Note
The paths below should be adjusted appropriately if using
pkgtools/xpkgwedge
.
-
Install the
fonts/ms-ttf
package from pkgsrc. If you use the pkgsrc version of X, install also thefonts/mkfontscale
andfonts/fontconfig
packages. -
If using the XFree86 shipped with NetBSD, you may consider using
fonts/fontconfig
from pkgsrc as it offers more tweaking options. Set the variablePREFER.fontconfig
to pkgsrc in the/etc/mk.conf
file to ensure that the pkgsrc version is used in favour of the shipped (or native) version:PREFER.fontconfig=pkgsrc
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):<dir>/usr/pkg/lib/X11/fonts/TTF</dir>
The
local.conf
file 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.conf
file. The following lines are for using teTeX-3.0 and ghostscript fonts:<dir>/usr/pkg/share/texmf-dist/fonts/</dir> <dir>/usr/pkg/share/ghostscript/fonts</dir>
-
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.dir
andfonts.scale
in 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
~/.xinitrc
(or~/.xsession
) file: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-list
it 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
fonts/vera-ttf
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
You haven't run 'fc-cache -v
' like the
fonts/fontconfig
MESSAGE
suggests during installation. For details, see
'pkg_info -D fontconfig
' and above.
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
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 twm in our examples (which comes with X), whose binary
is named twm
:
You can see that the content for each file is the same, so you may want to create a link between them.
Compiling programs
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.
A freeware implementation of Motif called Lesstif is also available.
It is available as part of the NetBSD packages collection,
under x11/lesstif
.
Compile fails - 'unable to locate xpm.h', or '-lXpm: no match' (top)
xpm.h
is part of the X PixMap
library, used by many programs to allow more multi (than
two) colour icons.
It is available as part of the NetBSD packages collection,
under graphics/xpm
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
line.
Back to em>NetBSD Documentation