Title : FreeBSD 12.1 on a laptop
Author: Solène
Date  : 11 May 2020
Tags  : freebsd mate laptop

# Introduction

I'm using FreeBSD again on a laptop for some reasons so expect to read more
about FreeBSD here. This tutorial explain how to get a graphical desktop using
FreeBSD 12.1.

I used a Lenovo Thinkpad T480 for this tutorial.


# Intel graphics hardware support

If you have a recent Intel integrated graphic card (maybe less than 3 years),
you have to install a package containing the driver:

    pkg install drm-kmod

and you also have to tell the system the correct path of the module (because
another i915kms.ko file exist):

    sysrc kld_list="/boot/modules/i915kms.ko"


# Choose your desktop environnement

## Install Xfce

    pkg install xfce

Then in your user `~/.xsession` file you must append:

    exec ck-launch-session startxfce4


## Install MATE

    pkg install mate

Then in your user `~/.xsession` file you must append:

    exec ck-launch-session mate-session


## Install KDE5

    pkg install kde5

Then in your user `~/.xsession` file you must append:

    exec ck-launch-session startplasma-x11


# Setting up the graphical interface

You have to enable a few services to have a working graphical session:

- **moused** to get laptop mouse support
- **dbus** for hald
- **hald** for hardware detection
- **xdm** for display manager where you log-in

You can install them with the command:

    pkg install xorg dbus hal xdm

Then you can enable the services at boot using the following commands, order is
important:

    sysrc moused_enable="yes"
    sysrc dbus_enable="yes"
    sysrc hald_enable="yes"
    sysrc xdm_enable="yes"

Reboot or start the services in the same order:

    service moused start
    service dbus start
    service hald start
    service xdm start

**Note that xdm will be in qwerty layout.**


# Power management

The installer should have prompted for the service powerd, if you didn't
activate it at this time, you can still enable it.

Check if it's running

    service powerd status

Enabling

    sysrc powerd_enable="yes"

Starting the service

    service powerd start


# Webcam support

If you have a webcam and want to use it, some configuration is required in
order to make it work.

Install the package webcamd, it will displays all the instructions written
below at the install step.

    pkg install webcamd

From here, append this line to the file `/boot/loader.conf` to load webcam
support at boot time:

    cuse_load="yes"

Add your user to the webcamd group so it will be able to use the device:

    pw groupmod webcamd -m YOUR_USER

Enable webcamd at boot:

    sysrc webcamd_enable="yes"

Now, you have to logout from your user for the group change to take place. And
if you want the webcamd daemon to work now and not wait next reboot:

    kldload cuse
    service webcamd start
    service devd restart

You should have a /dev/video0 device now. You can test it easily with the
package `pwcview`.

# External resources

I found this blog very interesting, I wish I found it before I struggle with
all the configuration as it explains how to install FreeBSD on the exact same
laptop. The author explains how to make a transparent lagg0 interface for
switching from ethernet to wifi automatically with a failover pseudo device.

[https://genneko.github.io/playing-with-bsd/hardware/freebsd-on-thinkpad-t480/](https://genneko.github.io/playing-with-bsd/hardware/freebsd-on-thinkpad-t480/)