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
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
- XChat - graphical irc client
- GKrellM - A very nice looking system monitoring tool with many plugins
- WMWeather - A handy little box that sits in the corner of the screen and displays the current weather
- Gaim - IM client that supports MSN, Yahoo, AIM, Jabber, ICQ, and many others
- Mozilla - web browser and mail client
- Liferea - RSS Reader
- mplayer - plays movies
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.
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