Web www.freebsdmadeeasy.com
Main Menu

Other Sites





Setting up X.org and FluxBox on FreeBSD

In addition to being a great server FreeBSD can make a great workstation. This tutorial will take you through the basics of getting X.org running on FreeBSD with a window manager and introduce you to a few other great applications on X.org.

Before Installing X.org

Before installing X.org is it a good idea to run Cvsup to get the lastest version of the port.

You will also need to place the following line into your /etc/make.conf file to declare that you are going to be using X.org instead of the XFree86 port.

X_WINDOW_SYSTEM=xorg

Installing X.org

X.org can be installed from the ports with the following commands

# cd /usr/ports/x11/xorg
# make install

The process of compiling X.org may take a while depending on the speed of your machine.

Configuring X.org

The installation is the easy part, now comes the hard part of configuring your hardware in X.org. The best way to do this is use the X.org config script as root

# xorgconfig

Mouse Protocol
- If you do not know choose Auto or Sysmouse and it will usually work.

Emulate 3 Button Protocol
- If you have a 3 button mouse, or a mouse with a wheel (counts as a 3rd button) choose no. Otherwise you need to hit yes. This allows you to press both buttons to represent the 3rd button which is needed for pasting text.

Mouse Device
- Unless your mouse is set to something else just hit enter to use the default of /dev/sysmouse

Keyboard
- If in doubt, press 1

XKB
- If you do not know what this is, choose no

Monitor
- This is one of the more important parts. If you choose incorrectly you could damage your monitor. Some monitors will tell you the hsync and vsync under their menu. Others you will need to search for online. The best way to find the hsync and vsync is to look up the monitor's model number which you can find on the back of the monitor. You can search on a search engine for the model number along with the term hsync and hopefully find it. If you are unable to find the hsync and vsync anywhere then you can try using one of the generic ranges given on the menu. When you find the range go to enter your own range and put the numbers in using the format that the others are in.

Video Card
- Here you definitely want to look at the card database. When going through it you want to look for a card with the same chipset as yours if your card is not listed. The chipset is what counts here, not the maker of the card since many makers implement a number of chipsets. If you get an error when trying to start X.org later it is probably because you choose the wrong chipset. Often it takes several trys to find the correct one, or researching your card online to see what other people choose for it. This can be a hassle, especially with onboard cards, but if you keep at it you will probably find the chipset is on the list somewhere.

Video Memory
- This is in KB so you will need to multiply the number of MB of memory your card has by 1024 and enter it in. Normally this is just hashed out in the X.org config file so it is not of high importance that you get it right.

Resolutions
- Choose some resolutions that are somewhat low if you are unsure what how high your card can handle in X.org. You only need to get it to run the first time, then you can come back and set them higher.

Once you have finished the script it will write the file to /etc/X11/xorg.conf

/etc/X11/xorg.conf

The following is an example of setting up the resolution for 1280x1024 and 1024x768 at 24M colors.

Section "Screen"
    Identifier  "Screen 1"
    Device      "onboard"
    Monitor     "mx70"
    DefaultDepth 24

    Subsection "Display"
        Depth       24
        Modes       "1280x1024" "1024x768"
        ViewPort    0 0
    EndSubsection
EndSection

Here the resolutions must be written in order of largest to smallest or you will be scrolling around on your desktop. To change between these two resolutions you would press ctrl+alt+"+" to get a higher resolution, and ctrl+alt+"-" to get smaller. And yes, that is control, alt, plus. All held down at once and in that order.

Setting up a wheel mouse

To add support for the wheel on a mouse the last two lines in the following example are needed to map the buttons

    Identifier  "Mouse1"
    Driver      "mouse"
    Option "Protocol"    "Auto"
    Option "Device"      "/dev/sysmouse"
    Option      "Buttons"       "5"
    Option      "ZAxisMapping"  "4 5"

Installing a Window Manager

After setting up X.org a Window Manager should be installed to help organize the desktop and make things all around easier. There are many to choose from in /usr/ports/x11-wm All the major ones are there such as KDE and Gnome. If you are looking for something similiar to windows one of these is a good choice. In this tutorial however we will be using FluxBox, which is a very light weight wm that is simple to use and configure. It can be installed from the ports at /usr/ports/x11-wm/fluxbox A gui also available for configuring fluxbox at /usr/ports/x11-wm/fluxconf

For more on setting up fluxbox read the Fluxbox tutorial.

Launching programs on startup with ~/.xinitrc

The .xinitrc file is run when X.org starts up, so this is where we need to place everything we want to load at startup. A basic .xinitrc file could look like this

exec xterm &
exec fluxbox

The above file would launch an xterm terminal and then load the window manager, which in this case is fluxbox. All programs being launched need an & after them so they will run in the background, the window manager however does not. Any program can be added to this file. If you wanted to also launch gkrellm and gaim on startup it would look something like this

exec xterm &
exec gaim &
exec gkrellm &
exec fluxbox

Starting X.org

Now that the .xinitrc file has been created X.org can be started by typing

# startx

X.org can be stopped by pressing ctrl+alt+backspace

If you have problems starting x go back and reconfigure your /etc/X11/xorg.conf file.

Setting the background

Once X.org is running the first thing you will want to do is get rid of the horrid default background. This can be done using either feh (/usr/ports/graphics/feh), Eterm (/usr/ports/x11/eterm), or a number of other programs not covered here. To set a file called mybg.jpg in your home dir to the background it would look like this in the two mentioned programs

# feh --bg-center ~/mybg.jpg

# Esetroot ~/mybg.jpg

In FluxBox one of these commands can be placed under the root command in a theme file which are found under ~/.fluxbox/styles This will automatically load that background when you choose the theme.

Getting Transparent Terminals

Both Eterm (/usr/ports/x11/eterm) and Wterm (/usr/ports/x11/wterm) allow for transparent terminals. In Wterm the options needed are

# wterm -fg white -tr

This creates a clear window with white text. If you have a very dark background this is alright, but in most cases you will want to add shading to make your text more readable.

# wterm -bg green -fg white -tr -sh

The above command creates a terminal window with a green transparent background and white text.

A clear transparent window in Eterm is created with

# Eterm --buttonbar=0 --trans -v -f white

A window shaded at 60% blue is created with

# Eterm --buttonbar=0 --trans --shade=60 --tint=blue -v -f white

To add these to your fluxbox menu (~/.fluxbox/menu) you would insert the follow sub group

[submenu] (Terminals)
[exec] (Wterm Blue) {wterm -bg blue -fg white -tr -sh}
[exec] (Wterm Green) {wterm -bg green -fg white -tr -sh}
[exec] (Wterm Red) {wterm -bg red -fg white -tr -sh}
[exec] (Wterm Orange) {wterm -bg orange -fg white -tr -sh}
[exec] (Wterm Clear) {wterm -fg white -tr}

[exec] (Eterm 20 Purple) {Eterm --buttonbar=0 --trans 
		--shade=20 --tint=purple -v -f white}
[exec] (Eterm 20 Gray) {Eterm --buttonbar=0 --trans 
		--shade=20 -v -f white}
[exec] (Eterm 60 Gray) {Eterm --buttonbar=0 --trans 
		--shade=60 -v -f white}
[exec] (Eterm 60 Blue) {Eterm --buttonbar=0 --trans 
		--shade=60 --tint=blue -v -f white}
[exec] (Eterm Clear) {Eterm --buttonbar=0 --trans
		-v -f white}
[end]

Useful Programs

Here are some useful programs for everyday activities if you are using X


Comments

Submitted by Bill Tillman on Sep 11, 2007
These are some excellent tutorial subjects, but like most *nix documentation there is a general attitude or lack of effort to really spell out the things that will be or need to be happening. Many times I‘ve been frustrated because some doc will tell you steps 1,2,3,7 & 8 in a process and will leave off steps 4,5 & 6 assuming anyone who is working with *nix will know these are required.
 
 My first attempts to ask questions about how to install Apache way back in 1998 were replied to with, "download a copy and install it". Anyone who has installed Apache from source knows this is not enogh information to get it done.
 
 And example above that references the making of xorg says it will take some time depending on your machine speed. This really should say more. I built xorg on a screaming AMD64 2.4 Ghz machine last night and it took 75 minutes. That‘s a more detailed answer that will let users know that they should not assume something is wrong if they go and have dinner and then come back and xorg is still building. To be honest about this, most people will be using slower machines and building xorg can and usually does take all night, even days on slower machines. I built it on a P166 with 96MB of RAM a few weeks ago and it took almost two days. This is what I‘m talking about. Don‘t leave new FreeBSD users in the dark assuming they will just find these things out for themselves.
Submitted by Lisandro Grullon on Oct 1, 2007
Hi Bill Tillman,
 To certain extand I do agree with you that the details are usually hidden in the *nix/Linux world, that is the point you are using a non-*indows OS, is all about research. How much interest you have to make something work your way, like you said, installing apache is not just download as install, there is more than that. That is why we have documentation in place to read it, and if you still have question, there are forums and newsgroup to ask and get more logical answers. Building xorg can take quite sometimes. I am running 7.3 now and the upgrade from 6.9 took over 3 days in one of my old boxes.
 
 Sometimes, us the writers assume that the person that is reading our writing have some sense of what he/she is doing. Remember, Unix expect you to know what you doing, there is not undo buttom like in *indows, you only source will be your last backup if you did it properly. Great article overall. Keep it going.
 
 Lisandro Grullon
Ask a question or add a comment here.