X Window System on FreeBSD
Part of the "Exploring FreeBSD on a Laptop" series.
Tested on FreeBSD 14.2
FreeBSD does not include a graphical user interface in its base system. This is how I install and set up the X Window System (X11) before installing my preferred window manager or desktop environment.
Installation
Install the xorg
meta package that provides the essential components of X11:
# pkg install xorg
Its required that my user be a member of the video
group. To add a user (example: foo
) to this group, run:
# pw groupmod video -m foo
Graphic Cards
Identify which graphics card is installed:
$ pciconf -lv|grep -B4 VGA
vgapci0@pci0:0:2:0: class=0x030000 rev=0x07 hdr=0x00 vendor=0x8086 device=0x5917 subvendor=0x17aa subdevice=0x2258
vendor = 'Intel Corporation'
device = 'UHD Graphics 620'
class = display
subclass = VGA
My laptop has a single Intel integrated graphics card. The graphics/drm-kmod
package provides a range of kernel modules for use with Intel graphics cards:
# pkg install drm-kmod
Add the module to the rc.conf
file using the sysrc(8) command:
# sysrc kld_list+=i915kms
Reboot the machine and observe as there is a brief flash on the screen as the kernel module is loaded during boot.
See Graphic card packages for details on other graphic cards such as AMD and NVIDIA.
Fonts
The x11-fonts/urwfonts
package includes standard type1 fonts (Times Roman
, Helvetica
, Palatino
, and others). Fonts firacode
and ubuntu-font
I always like to install for use in xterm(1) and windows and menus in X11 environments. Font noto-emoji
helps to render emoji in Firefox web browser:
# pkg install urwfonts firacode ubuntu-font noto-emoji
Xinit
The xinit(1) program is used to start the Xorg display server, usually by running the startx(1) front-end script:
$ startx
Run this command to test Xorg. If you see the very simple TWM(1) window manager and graphical applications can be opened, Xorg is working correctly.
Per user configuration is set by copying the system configuration to the user's home directory and adjusting to taste:
$ cp /usr/local/etc/X11/xinit/xinitrc ~/.xinitrc
A few adjustments I like to make in my own .xinitrc ....
Keyboard
If using a non-US keyboard mapping, use setxkbmap(1) to set the alternative.
Example: I use the colemak
keyboard:
setxkbmap -model pc104 -layout us -variant colemak
Janitor
Empty the trash:
usertrash=$HOME/.local/share/Trash
if [ -d $usertrash ]; then rm -rf $usertrash; fi
Backlight
Set the display to maximum brightness
backlight 100
Display Timeout
Default settings for Xorg has the screen saver configured (in seconds) to timeout: 600 cycle: 600
, and DPMS (Display Power Management Signaling) also has Standby: 600 Suspend: 600 Off: 600
.
View all settings (inside an Xorg session) with the xset(1) command:
$ xset q
I find 10 minutes to a blank screen too short, but I don't want to disable the functionality entirely.
To modify the duration of time (30 minutes) in the current Xorg session before the screen saver kicks in:
$ xset s 1800 1800; xset dpms 1800 1800 1800; xset q
Make the change persist across sessions by adding to .xinitrc
:
xset s 1800 1800
xset dpms 1800 1800 1800
Xresources
Per user configuration for X client applications can be set by creating the ~/.Xresources
file.
Colours
I like the Nord colour palette. I set these colours for use by xterm
(and other X applications with the *<setting>
wildcard) by adding to my own .Xresources file:
! Colors
*background: #000000
*foreground: #d8dee9
*cursorColor: #bf616a
! Nord palette
! black
*color0: #4c566a
*color8: #000000
! red
*color1: #bf616a
*color9: #bf616a
! green
*color2: #a3be8c
*color10: #a3be8c
! yellow
*color3: #ebcb8b
*color11: #ebcb8b
! blue
*color4: #5e81ac
*color12: #5e81ac
! magenta
*color5: #b48ead
*color13: #b48ead
! cyan
*color6: #88c0d0
*color14: #88c0d0
! white
*color7: #d8dee9
*color15: #ffffff
Test the status of your colour support with:
$ tput colors
If it reports 256
then the system is in good shape.
Xcursor
Set the cursor size and the theme:
Xcursor.theme: whiteglass
Xcursor.size: 32
Other themes include redglass
and handhelds
and are included in the x11-themes/xcursor-themes
package.
To set the cursor on the root window of the Xorg session, its also necessary to edit ~/.xinitrc
by adding the xsetroot(1) command:
xsetroot -cursor_name [name]
Example:
xsetroot -cursor_name left_ptr
Other options for [name]
include: X_cursor
, gumby
, ul_angle
, ur_angle
, right_ptr
Xterm
I use xterm(1) as my terminal application in Xorg. It has a big man page and I'm still exploring all the options and settings. This is what I've configured so far and I'm quite happy with it.
Window Managers and Desktops
TODO
After Xorg is configured to your satisfaction, its time to pick a window manager or desktop environment (or stick with twm
). I like Openbox.
Resources
- My config files:
- FreeBSD Handbook: The X Window System
- FreeBSD Desktop series by vermaden: X11 Window System
You can like, share, or comment on this post on the Fediverse 💬
» Next: Exploring FreeBSD on a Laptop
« Previous: Networking on a FreeBSD Laptop