Howto: light desktop setup (2018 < update)

Xinit and XDM login managers are covered. KDM, GDM, WDM and SLiM login managers are not described here.

Install
The following are sufficient to install the programs for a running Desktop system: x11/xorg, x11/xdm and your chosen window manager. If you're not using a graphical desktop login manager, xdm can be omitted.

Desktop login
Configuration files for Xinit and XDM are under the /usr/local/etc/X11/ and ~/ directories, respective to Xinit and XDM. The minimal configuration for .xsession or .xinit in your home directory is:
Code:
#!/bin/sh
exec /usr/local/bin/<windowmanager>
Console
Set .xinitrc in each home folder, to load custom settings from that user's command line. The default /usr/local/etc/xinit/xinitrc points to several other files in your home directory.

Make sure the owner file permissions of .xinitrc are at minimum set to read.
chmod 440 .xinitrc

Finally, type startx.

XDM
To configure x11/xdm to start up on boot, edit /etc/ttys and change the option on line ttyv8 from off to on:
Code:
ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   '''on''' secure
The secure option allows logging in to the root console without a password from single user mode.

Set up .xsession with owner and group permissions to read and execute. If you soft link .xsession and .xinitrc together, both permissions must be 550.
Code:
ln -s .xsession .xinitrc
chmod 550 .xsession
Under normal circumstances, /usr/local/etc/X11/xdm/Xsession should be left alone, because this file by default points to ~/.xsession and ~/.xsession-errors.

Customization
Customization files for XDM are located in /usr/local/etc/X11/xdm/.

The background image or color can be changed with a command argument in Xsetup_0. xsetroot can set the background to a color or bitmap image. To choose a common image type, use a program such as x11/bgs or graphics/feh from within Xsetup_0.

Example of Xsetup_0:
Code:
#!/bin/sh
bgs /home/mydirectory/mypicture.png &
#xconsole &
The reference to x11/xconsole, used for displaying terminal output, such as attached devices, can optionally be commented out.

It is important to add an & after adding new configuration commands, or the login screen will freeze up with certain commands.

To change the box logo, edit Xresources, comment out or reference another .xpm file in the lines xlogin*logoFileName.

Desktop programs
Read the documentation of your chosen window manager's configuration files to load desktop programs, if it is available. If your window manager doesn't have the ability to load desktop programs, use .xsession or .xinitrc, to start them. Background programs, such as x11/xrandr, should be loaded with .xsession or .xinitrc.

Example of .xsession or .xinitrc:
Code:
#!/bin/sh
xterm &
xclock &
exec jwm
Programs are loaded with &, and the window manager is loaded last with exec.

BSD Desktops
Thread BSD Window Managers; List.63710

Notes
Most of this is common information, but the updates are put into one spot.
Also at: http://freebsdwiki.net
 
Driver and Hardware configuration
xorg.conf
Xorg is now mostly auto-configured. xorg.conf is replaced by the directory /usr/local/etc/X11/xorg.conf.d/ for specific configurations only. The syntax of a configuration filename in this directory is <customname>.conf.
Basic hardware
To enable the mouse and keyboard, considering that recent versions of xorg are set to use autodetection by default.

Add the following to /etc/rc.conf:
Code:
dbus_enable="YES"
For customizing mount options of devfs(8), use /etc/fstab:
Code:
devfs      /dev       devfs     rw   0 0
fdescfs    /dev/fd    fdescfs   rw   0 0
fdescfs(5) can alternatively be loaded through compiling in the kernel or through /boot/loader.conf.
GPU Drivers
For a list of FreeBSD supported video cards, https://wiki.freebsd.org/Graphics#Hardware_Support. Check the latest compatibility information before purchasing a graphics card. Different brands of video cards generally don't work well together.

The VESA driver works with sc(4). Graphics cards which use KMS (ATI and Intel) need the vt(4) driver. Most video drivers can be selected for installation by running make config from x11-drivers/xorg-drivers. To automate this, edit make.conf, and recompile x11-drivers/xorg-drivers. If another driver is specified and configured, removing the VESA driver and its SCFB dependency are optional.
Code:
x11-drivers_xorg-drivers_UNSET=VESA SCFB
The argument to select specific driver for installation from x11-drivers/xorg-drivers is under the respective section below.

When you set these cards, permissions must be set to allow access for them through /etc/devfs.rules:
Code:
[localrules=10]
add path 'dri/*' mode 0666 group video # changed from operator
Be sure this location is referenced through rc.conf:
Code:
devfs_system_ruleset="localrules"
Add your user to the video group, in /etc/group.

Do not load ATI, Intel or Nvidia cards by compiling their drivers into the kernel. ATI and Intel drivers are capable of auto-loading, but setting them in /etc/rc.conf will prevent them from falling back to the VESA driver for the console. Don't load ATI and Intel drivers through /boot/loader.conf.
ATI
Many ATI Radeon cards are compatible with FreeBSD. However, not all outputs or functions may work on partially supported video cards.

Radeon cards require the ATI setting in x11-drivers/xorg-drivers, and here is how to set it for installation through make.conf:
Code:
x11-drivers_xorg-drivers_SET=ATI
To configure the Radeon driver to load on boot-up, add the following to rc.conf:
Code:
kld_list="radeonkms"
The setting AMDGPU in x11-drivers/xorg-drivers for newer video drivers is not ready for FreeBSD 11.1 and previous versions. MACH64 and R128 are only required if you have those specific older models.

Experimental Radeon card support by graphics/drm-next-kmod in FreeBSD 12 (current), can be enabled by rc.conf:
Code:
kld_list="amdgpu"
# or
kld_list="/boot/modules/radeonkms.ko"
Intel
To set Intel cards for installation, use this argument in make.conf:
Code:
x11-drivers_xorg-drivers_SET=INTEL
To load an Intel graphics card on start up, insert into rc.conf:
Code:
kld_list="i915kms"
Broadwell, Skylake and Kabylake Intel cards are expected to be functional in FreeBSD 12 (current): as of now, they are represented in graphics/drm-next-kmod. If you're testing this driver on current, set an absolute path, instead of the default, in rc.conf to:
Code:
kld_list="/boot/modules/i915kms.ko"
Nvidia
The driver for older Nvidia cards can be set to install by using this argument in make.conf:
Code:
x11-drivers_xorg-drivers_SET=NV
Other Nvidia drivers are x11/nvidia-driver, x11/nvidia-driver-340 or x11/nvidia-driver-304. There are examples of these cards loaded through either /boot/loader.conf or /etc/rc.conf.

Some users set /etc/rc.conf to either of:
Code:
kld_list+="nvidia-modeset"
# or
kld_list+="nvidia"
Other users set /boot/loader.conf to:
Code:
nvidia_load="YES"
nvidia-modeset_load="YES"
The following is often used with loading the Nvidia driver through loader.conf. Linux based ports need it to use Nvidia cards' advanced features. To not use it, Linux options from the Nvidia card must be turned off, (this can be set automatically from /boot/loader.conf: see linux(4)).
Code:
linux_load="YES"

* edited Nvidia section; 2018 March 07

For more on configuring Nvidia cards, see Thread HOWTO: Setup Xorg with NVIDIA's driver.52311 by tobik@.
Notes
Relating to drivers for FreeBSD 12 (current), use the FreeBSD mailing list, https://lists.freebsd.org/mailman/listinfo/freebsd-current, or keep it on this thread. Thread Topics-about-unsupported-FreeBSD-versions.40469

* edits: scfb syscons driver UNSET option (2018); corrected file name to loader.conf, and added Linux manpage (2021).
 
Last edited:
Multiple Monitors
Use the program x11/xrandr to be able to use and configure multiple monitors. With this program, a video card can use its supported HDMI, DVI and other outputs for multiple monitor displays.

Example that can be used from .xinitrc or .xsession:
Code:
xrandr --output DVI-0 --right-of HDMI-0
Edit: x11/arandr is another tool which has graphical interface for this. It can be used to get desired and complex settings for xrandr, as well.
 
Multiple Monitors
Use the program x11/xrandr to be able to use and configure multiple monitors. With this program, a video card can use its supported HDMI, DVI and other outputs for multiple monitor displays.

Example that can be used from .xinitrc:
Code:
xrandr --output DVI-0 --right-of HDMI-0
I would have loved to see this in the handbook 2 years ago, it drove me mad trying to find out how to do that. Also, x11/lumina-coreutils contains lumina-xconfig which allows doing this visually. Super handy for that last-minute panic when getting a presentation ready to share on dual screen / projector.
 
I would have loved to see this in the handbook 2 years ago, it drove me mad trying to find out how to do that. Also, x11/lumina-coreutils contains lumina-xconfig which allows doing this visually. Super handy for that last-minute panic when getting a presentation ready to share on dual screen / projector.
I used Arch Linux documentation and manpages to find out how to set xrandr(1). Then I've written this elsewhere, http://freebsdwiki.net/index.php/Hardware_Configuration,_Audio/Video#Multiple_Monitors
So, any output supported by the driver, can run multiple video outputs from one card. I've run 3 different outputs off of 1 card before: HDMI, DVI and VGA. I only tested VGA to see if it worked, the resolution is poor compared to the others.

Xrandr will also let you display different monitors as lanscape or portrait.
 
Are you suggesting that on needs the Linux kernel
Code:
linux_load="YES"
to use the Nvidia graphics driver?
As of the newest (LTS) driver downloaded directly from Nvidia, it seems no longer possible to compile without linux compatibility You can unset that option, just to find that your setting gets ignored. With the driver from packages, the linux compatibility is always included. If you do not include the linux_load line, you'll find that nvidia_load pulls in that module itself.
So, strictly spoken, it is not necessary to include that line :)
 
Hi Snurg,

thank you for the reply. I find it rather strange that a driver for FreeBSD requires an entire Linux kernel.

Kindest regards,

M
 
Hi tobik@,

thank you for the reply, I will try to compile the port with the option off.

Just for my education, why a port, which is intended for FreeBSD has a Linux compatibility turned on? Would the logical way not be the opposite, so that people who know that they will use Linux compatibility would turn it on?

Hi sidetone,

perhaps you may incorporate tobik@'s clarification?

Kindest regards,

M
 
Hi tobik@,

thank you for the reply, I will try to compile the port with the option off.

Just for my education, why a port, which is intended for FreeBSD has a Linux compatibility turned on? Would the logical way not be the opposite, so that people who know that they will use Linux compatibility would turn it on?
Yeah, I don't like it either. But we have many Linux applications and games in the ports tree. Having LINUX off by default would mean that the binary packages of any of the */linux-* ports (e.g. games/linux-doom3) or other Linux applications will not have working 3D acceleration with NVIDIA GPUs. x11/nvidia-driver only installs a Linux version of LibGL when the LINUX option is on.
 
mefizto
I just pointed out, that there were two different ways they did it, that I observed posted on the forums. One way I posted didn't use /boot/loader.conf with loading the linux module. Using kld_list= from /etc/rc.conf is supposed to be the way to go, but many insist on using loader.conf and loading linux compatibility.

I'm unable to test Nvidia. Go with what tobik@ says. It also seems reasonable that the linux kernel module is only for those that need it as a dependency. If I could avoid it, I would. You can test out both, and see what works. Often, trial and error of different configurations, helps me understand what is supposed to work, and what doesn't.

I included Nvidia to be inclusive of all cards, and information on Nvidia was based on the forums, and what other people could confirm.

I'm wondering if kld_list= in rc.conf can be used with enabling Linux compatibility in /boot/loader.conf, for only ports that require the option for Linux compatibility. If you are confident in your answer, you can post your results below.
 
The following are sufficient isto install the programs for a running Desktop system: x11/xorg, x11/xdm and your chosen window manager
I have learned this in hard way. New users may avoid installing x11/xorg-minimal , this will not pull x11-drivers/xorg-drivers, so to left with vesa. Also they may require to install other required ports.
Another problem is with pkg install way. As this uses default options, there is no way to install GPU drivers. One have to be alert for information of other required drivers/packages from https://www.freshports.org/ or this forums.
For my systems latest ati & intel drivers enable correct resolution for vt & X windows and (suspend)/resume function.
 
I have learned this in hard way. New users may avoid installing x11/xorg-minimal , this will not pull x11-drivers/xorg-drivers, so to left with vesa. Also they may require to install other required ports.
Another problem is with pkg install way. As this uses default options, there is no way to install GPU drivers. One have to be alert for information of other required drivers/packages from https://www.freshports.org/ or this forums.
For my systems latest ati & intel drivers enable correct resolution for vt & X windows and (suspend)/resume function.
I've explained above how to compile x11/xorg and x11-drivers/xorg-drivers to automatically leave out VESA (x11-drivers/xf86-video-vesa), exclude any other video driver, or include any video driver through make.conf.
 
Status of amdgpu and other video drivers on FreeBSD 11.2-BETA3.
First, I had to install sources from FreeBSD 11-stable in order to compile graphics/drm-stable-kmod. Finally, Radeon modules became available at /boot/modules/.

/etc/rc.conf:
Code:
kld_list="amdgpu" # or
kld_list="/boot/modules/radeonkms.ko" # or
kld_list="/boot/modules/i915kms.ko"
With amdgpu set, the console is able to boot with the Radeon driver. Xorg also starts up, without requiring x11-drivers/xf86-video-vesa and x11-drivers/xf86-video-scfb, provided that x11-servers/xorg-server is built with ports from scratch, with corresponding options.

Users were added to the video group in /etc/groups/.

The edited permissions to /dev/drm/ from /etc/devfs.rules:
Code:
add path 'dri/*' mode 0666 group video # changed from operator to video
add path 'drm/*' mode 0666 group video # added

kldstat shows the updated drivers:

Code:
4     1 0xffffffff82435000 14b1d8   amdgpu.ko
5     1 0xffffffff82581000 6e610    drm.ko
6     4 0xffffffff825f0000 edc8     linuxkpi.ko
7     3 0xffffffff825ff000 e200     linuxkpi_gplv2.ko
8     2 0xffffffff8260e000 6c0      debugfs.ko
9     1 0xffffffff8260f000 23f7     radeon_kaveri_pfp_bin.ko
10    1 0xffffffff82612000 23f5     radeon_kaveri_me_bin.ko
11    1 0xffffffff82615000 23f5     radeon_kaveri_ce_bin.ko
12    1 0xffffffff82618000 43f7     radeon_kaveri_mec_bin.ko
13    1 0xffffffff8261d000 43f9     radeon_kaveri_mec2_bin.ko
14    1 0xffffffff82622000 2a77     radeon_kaveri_rlc_bin.ko
15    1 0xffffffff82625000 12e9     radeon_kaveri_sdma_bin.ko
16    1 0xffffffff82627000 12eb     radeon_kaveri_sdma1_bin.ko
17    1 0xffffffff82629000 38ea7    radeon_kaveri_uvd_bin.ko
18    1 0xffffffff82662000 18c47    radeon_kaveri_vce_bin.ko

dmesg|grep -i radeon gave the output with error messages:
Code:
CPU: AMD A6-7400K Radeon R5, 6 Compute Cores 2C+4G   (3493.54-MHz K8-class CPU)
radeon/kaveri_pfp.bin: could not load firmware image, error 2
radeon/kaveri_pfp.bin: could not load firmware image, error 2
radeon/kaveri_me.bin: could not load firmware image, error 2
radeon/kaveri_me.bin: could not load firmware image, error 2
radeon/kaveri_ce.bin: could not load firmware image, error 2
radeon/kaveri_ce.bin: could not load firmware image, error 2
radeon/kaveri_mec.bin: could not load firmware image, error 2
radeon/kaveri_mec.bin: could not load firmware image, error 2
radeon/kaveri_mec2.bin: could not load firmware image, error 2
radeon/kaveri_mec2.bin: could not load firmware image, error 2
radeon/kaveri_rlc.bin: could not load firmware image, error 2
radeon/kaveri_rlc.bin: could not load firmware image, error 2
radeon/kaveri_sdma.bin: could not load firmware image, error 2
radeon/kaveri_sdma.bin: could not load firmware image, error 2
radeon/kaveri_sdma1.bin: could not load firmware image, error 2
radeon/kaveri_sdma1.bin: could not load firmware image, error 2
radeon/kaveri_uvd.bin: could not load firmware image, error 2
radeon/kaveri_uvd.bin: could not load firmware image, error 2
radeon/kaveri_vce.bin: could not load firmware image, error 2
radeon/kaveri_vce.bin: could not load firmware image, error 2

These messages correspond to the output of kldstat above. graphics/gpu-firmware-kmod is already installed as a dependency. After using dmesg | grep -A4 radeon, it shows that these firmwares were found, but perhaps not immediately, thus giving these errors. Putting the corresponding modules next to kld_list=, before "amdgpu" in /etc/rc.conf got rid of these error messages. Usually, starting video drivers from /boot/loader.conf crashes the system, and any driver will, if started in the wrong order from here.

There are no errors in ~/.xsession-errors related to xorg or graphics drivers. The console and desktop work so far. Font sizes had to be adjusted for differences in resolution.

After having this, it's a good idea to set the VDPAU wrapper in make options for ports, because it is referenced from grep -i radeon /var/log/Xorg.0.log
/etc/make.conf:
Code:
OPTIONS_SET=VDPAU
Enable VDPAU for Intel cards too. I'm uncertain of VAAPI's relationship to VDPAU, and if it should also be enabled for port builds.

graphics/drm-next-kmod is for newer drivers according to its message at /usr/ports/graphics/drm-next-kmod/pkg-message: Radeon HD7000 Tahiti and newer, and Intel HD3000 Sandy Bridge and newer. The messages for both of these ports are cautioned not to work well from EFI drives.

That was an amazing job by graphics driver developers and maintainers to make this available.
 
XDM
...
To change the box logo, edit Xresources, comment out or reference another .xpm file in the lines xlogin*logoFileName.

Hi,

To change the box logo to Freebsd logo (BSD Daemon):

Install fig2dev and:
Code:
cd /usr/share/examples/BSD_daemon
fig2dev -L xpm -m 0.5 beastie.fig > /usr/local/share/pixmaps/bsd.xpm

To make the background transparent, edit bsd.xpm and change:
Code:
"o c White",
to
"o c none",

or patch:
Code:
--- bsd.xpm.orig        2020-02-14 22:21:31.012126000 +0000
+++ bsd.xpm     2020-02-14 22:21:30.975611000 +0000
@@ -6,7 +6,7 @@
 "  c Black",
 ". c #FFD600",
 "X c #00B000",
-"o c White",
+"o c none",
 "O c #D10000",
 "+ c Cyan",
 /* pixels */

Enjoy.

Taken from Complete XDM Working Example.

Nuno Teixeira
 
Although this topic is old, the xdm graphics manager for many is still quite confusing in its configuration and customization.
 
Not only the topic is old, so is XDM. First release was 1988 (32 years ago) and that's the reason for the laborious configuration.
The FreeBSD handbook only describes the configuration and customization files for xdm, don't detail with examples, and when you enter the window manager it automatically skips a window without detailing how to inactivate it.

The configuration and customization files for xdm are as described below, but how to configure and customize it to be optimal if there is no example in the handbook?

Code:
Xaccess

Xresources

Xservers

Xsession

Xsetup_*

xdm-config

xdm-errors

xdm-pid



 
2021 updates

Installing kernel video modules
For Radeon and Intel graphics hardware, install graphics/drm-kmod, which will install the available appropriate port that contains kernel drivers into /boot/modules/. This package and port both work well for established video hardware on FreeBSD 13. In early FreeBSD 12 releases, these packages weren't reliable. Newly supported cards may require building kernel modules from ports, or may require the use of FreeBSD Stable and kernel sources.

Nvidia has its own kernel modules in ports.

Inserting modules into rc.conf:
Code:
kld_load=""
  • "i915kms.ko" for Intel
  • "radeonkms.ko" or "amdgpu.ko" for Radeon, depending on type of hardware

User permissions must be set in /etc/devfs.rules:
Code:
add path 'dri/*' mode 0666 group video # changed from operator

Reference this rule in rc.conf and /etc/group.

These modules are useful for replacing VESA in the terminal, and it is a prerequisite for custom Xorg drivers. ATI and Intel drivers are capable of auto-loading, but setting them in /etc/rc.conf will prevent them from falling back to the VESA driver when dropping to the console.


Notes on KERNCONF and src.conf
A lot of specialized code also needed for modern drivers was consolidated into legacy graphics code. Video options of src.conf(5) and KERNCONF are needed for overlying modern graphics drivers to work correctly. Don't compile ATI (Radeon, AMDGPU), Intel or Nvidia modules or drivers into the kernel. Also, don't load Intel and Radeon modules in /boot/loader.conf. Use rc.conf for loading graphics modules.


Getting Desktop up and running
For getting a desktop running, I'll use pkg install with text file samples.

For terminal tools, and the graphics driver that can run in the terminal, cli.txt:
Code:
psearch portmaster doas
drm-fbsd13-kmod

Example for the quick desktop, desktop.txt:
Code:
xorg xdm ctwm jwm bspwm
birdtray thunderbird firefox hexchat
gvolwheel osdmixer deadbeef
wmmoonclock rxvt-unicode xscreensaver
drm-fbsd13-kmod
xf86-video-amdgpu
An entry was included in both, in case installing one of these sets is missed. Your specific Xorg driver can be used in these entries. x11/xorg-minimal can optionally be used in place of xorg.

Then run [doas] pkg install `cat cli.txt desktop.txt`. Alternatively, installing cli.txt first on its own command separated from desktop.txt allows me to do configurations while I wait for desktop programs to finish installing.


Xorg drivers
Install the video driver specific to Xorg for your hardware model, listed as /usr/ports/x11-drivers/xf86-video-[*]. This can also be selected from x11-drivers/xorg-drivers with make config. To hardset this option, for example, make.conf:
Code:
x11-drivers_xorg-drivers_SET=ATI
x11-drivers_xorg-drivers_UNSET=INTEL

If xorg and xorg-drivers are installed from packages, you may want to reinstall the specific (ATI, AMDGPU, INTEL) xorg driver from ports. This fixes unwanted display layout changes: it will keep the screen output with the same dimensions by the Xorg VESA driver. The rest of Xorg including other Xorg drivers don't have to be rebuilt from ports.


Continuing install
Installing some of these through ports would be time and processor intensive. After this, I'll use ports for more installs. Many advise against mixing ports and packages, but by using strategies, it can be done. Programs that require the same dependencies can be installed together as ports often without problems. Programming languages can be installed as packages, unless customized options are needed. When troubleshooting occurs, it take less time to rebuilt what's needed than to recompile everything. Rebuilding the program in question often fixes needed libraries.

To make a list of ports for using with portmaster, include the category in ports.txt:
Code:
math/abs
audio/xmixer
portmaster `cat ports.txt`

Configuring of xdm and the window manager is in previous entries in this thread.


Related threads; tags
 
I got the first or instruction part correct: graphics/drm-kmod. Then, got specific for my PC in the example.

Obviously, use drm-kmod, or the one specific to your FreeBSD version when installing from a text file. Any other specifics for the drm type may only apply to CURRENT, and in the past for STABLE, which those who use it will be able to know which one to choose.
 
Back
Top