Web www.freebsdmadeeasy.com
Main Menu

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