github gitlab mastodon email
FreeBSD - MacBook Wayland only setup

I decided to revive my old Macbook 4,1 (or early 2008 / A1181) and FreeBSD seemed like a good fit. In addition I wanted to see if I could achieve a Wayland-only setup I could use easily, knowing that my activities are mostly web browsing and shell.

The first thing was to get a booting install media, I had to use a 12.2 USB image as I couldn’t go past the loading kernel step on 13.0-RCX.

I basically followed the installer default choices and chose a non-encrypted ZFS option with UEFI(gpt), nothing fancy here. The only thing to notice is I could only configure the wired connection as the WiFi adapter is not usable out of the box.

Once the system up and running I decided to upgrade using freebsd-update to reach 13.0-RC5.

freebsd-update upgrade -r 13.0-RC5
freebsd-update install

Being an i3 user for a long time, and switching little by little to sway on the computers I reinstall, I decided to give it a try.

But first I had to make sure I could load the i915 drivers.

pkg install drm-kmod devcpu-data
kldload i915kms # seemed to load properly

The following modifications are required to get things loaded at boot time.

### loader.conf

### rc.conf

Once this is done, when I reboot, there’s a slight flicker then I see

[drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).
Successfully added WC MTRR for [0x80000000-0x8fffffff]: 0;
[drm] Got stolen memory base 0x7f000000, size 0x1000000
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
[drm] Failed to find VBIOS tables (VBT)
[drm] applying backlight present quirk
[drm] Connector LVDS-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.LVDS-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector VGA-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.VGA-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector DVI-D-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.DVI-D-1
[drm]   - kern.vt.fb.default_mode
[drm] Connector SVIDEO-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.SVIDEO-1
[drm]   - kern.vt.fb.default_mode
[drm] RC6 disabled, disabling runtime PM support
[drm] Initialized overlay support.
sysctl_warn_reuse: can't re-use a leaf (hw.dri.debug)!
[drm] Initialized i915 1.6.0 20190822 for drmn0 on minor 0
WARNING: Device "fb" is Giant locked and may be deleted before FreeBSD 14.0.
VT: Replacing driver "efifb" with new "fb".

Now I need to install my Wayland compositor of choice, Sway.

pkg install sway seatd
# in rc.conf
# then doas service seatd onestart or it will just start at next reboot

Then if you try to type sway, it fails and requires you to set an environment variable XDG_RUNTIME_DIR.

# Either interactively
setenv XDG_RUNTIME_DIR /tmp
# or in .cshrc
# after mkdir /var/run/sway and chowning it to my user
setenv  XDG_RUNTIME_DIR /var/run/sway

After that, I could simply type sway and it would load, but with a wrong keyboard layout and other wrong shortcuts and such. Also no terminal was installed, nor launcher menu.

I decided on Alacritty and bemenu, because I use them on another Ryzen based computer I own and they fit my needs.

But Alacritty turns out to have some issues running on such an old computer because of this issue. So I went looking for a replacement and I found out about foot, which at least can be started and gives me something usable.

I added some configuration in ~/.config/sway/config to have something more to my liking. Here’s the actual content of that file.

Note the xwayland disable option for Wayland only setup, the bemenu-run call to get the launcher, and the shortcuts configured for the azerty layout.

# Default config for sway
# Copy this to ~/.config/sway/config and edit it to your liking.
# Read `man 5 sway` for a complete reference.

xwayland disable

### Variables
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Your preferred terminal emulator
set $term foot
# Your preferred application launcher
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
#set $menu dmenu_path | dmenu | xargs swaymsg exec --
set $menu bemenu-run

### Output configuration
# Default wallpaper (more resolutions are available in /usr/local/share/backgrounds/sway/)
output * bg /usr/local/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
# Example configuration:
output LVDS-1 resolution 1280x800 position 0,0
# You can get the names of your outputs by running: swaymsg -t get_outputs

# day / night adjustement
#exec wlsunset -l 47.1 -L 5.0

### Idle configuration
# Example configuration:
#exec swayidle -w \
#          timeout 300 'swaylock -f -c 000000' \
#          timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
#          before-sleep 'swaylock -f -c 000000'
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.

### Input configuration
# Example configuration:
input * {
    xkb_layout fr,ru
    xkb_options grp:alt_shift_toggle
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.

### Key bindings
# Basics:
    # Start a terminal
    bindsym $mod+Return exec $term

    # Kill focused window
    bindsym $mod+Shift+q kill

    # Start your launcher
    bindsym $mod+d exec --no-startup-id $menu

    # Drag floating windows by holding down $mod and left mouse button.
    # Resize them with right mouse button + $mod.
    # Despite the name, also works for non-floating windows.
    # Change normal to inverse to use left mouse button for resizing and right
    # mouse button for dragging.
    floating_modifier $mod normal

    # Reload the configuration file
    bindsym $mod+Shift+C reload

    # Exit sway (logs you out of your Wayland session)
    bindsym $mod+Shift+E exit
# Moving around:
    bindsym $mod+Left focus left
    bindsym $mod+Down focus down
    bindsym $mod+Up focus up
    bindsym $mod+Right focus right

    bindsym $mod+Shift+Left move left
    bindsym $mod+Shift+Down move down
    bindsym $mod+Shift+Up move up
    bindsym $mod+Shift+Right move right
# Workspaces:
    # Switch to workspace
    bindsym $mod+ampersand workspace number 1:
    bindsym $mod+eacute workspace number 2:
    bindsym $mod+quotedbl workspace number 3:
    bindsym $mod+apostrophe workspace number 4:
    bindsym $mod+parenleft workspace number 5:
    bindsym $mod+minus workspace number 6:
    bindsym $mod+egrave workspace number 7:
    bindsym $mod+underscore workspace number 8:
    bindsym $mod+ccedilla workspace number 9:
    bindsym $mod+agrave workspace number 10:
    bindsym $mod+a workspace number a:
    # Move focused container to workspace
    bindsym $mod+Shift+ampersand move container to workspace number 1:
    bindsym $mod+Shift+eacute move container to workspace number 2:
    bindsym $mod+Shift+quotedbl move container to workspace number 3:
    bindsym $mod+Shift+apostrophe move container to workspace number 4:
    bindsym $mod+Shift+parenleft move container to workspace number 5:
    bindsym $mod+Shift+minus move container to workspace number 6:
    bindsym $mod+Shift+egrave move container to workspace number 7:
    bindsym $mod+Shift+underscore move container to workspace number 8:
    bindsym $mod+Shift+ccedilla move container to workspace number 9:
    bindsym $mod+Shift+agrave move container to workspace number 10:
    bindsym $mod+Shift+A move container to workspace number a:
# Layout stuff:
    # You can "split" the current object of your focus with
    # $mod+b or $mod+v, for horizontal and vertical splits
    # respectively.
    bindsym $mod+b splith
    bindsym $mod+v splitv

    # Switch the current container between different layout styles
    #bindsym $mod+s layout stacking
    #bindsym $mod+w layout tabbed
    #bindsym $mod+e layout toggle split

    # Make the current focus fullscreen
    bindsym $mod+f fullscreen

    # Toggle the current focus between tiling and floating mode
    bindsym $mod+Shift+space floating toggle

    # Swap focus between the tiling area and the floating area
    bindsym $mod+space focus mode_toggle

# Status Bar:
# Read `man 5 sway-bar` for more information about this section.
bar {
    position bottom
    mode dock
    output LVDS-1
    tray_output LVDS-1
    # When the status_command prints a new line to stdout, swaybar updates.
    # The default just shows the current date and time.
    status_command while date +'%Y-%m-%d %H:%M:%S %p'; do sleep 1; done

    colors {
        statusline #ffffff
        background #323232
        inactive_workspace #32323200 #32323200 #5c5c5c

font pango:Noto Mono 10

default_border pixel 1

include /usr/local/etc/sway/config.d/*

I got the output name correct for the bar output by running swaymsg -t get_outputs

Output LVDS-1 'Apple Computer Inc Color LCD 0x00000000' (focused)
  Current mode: 1280x800 @ 59.910000 Hz
  Position: 0,0
  Scale factor: 1.000000
  Scale filter: nearest
  Subpixel hinting: rgb
  Transform: normal
  Workspace: 4:
  Max render time: off
  Adaptive sync: disabled
  Available modes:
    1280x800 @ 59.910000 Hz

After all this I had a pretty decent sway running with a terminal. But I needed a web-browser, so I installed Firefox.

pkg install firefox dbus
# in /etc/rc.conf

doas service dbus start

And because I use xwayland disable in order not to use Xwayland, I had to set the following in .cshrc


After that Firefox starts without any issue and I was even able to play some videos on Youtube. I’m rather surprised of how good an old laptop like that still is for basic tasks.

A little excerpt from top when running sway + Firefox + a few foot terminals

last pid:  6019;  load averages:  0,13,  0,17,  0,18; battery: -1%                                                                     up 0+03:23:54  13:29:45
26 processes:  1 running, 25 sleeping
CPU:  4,1% user,  0,0% nice,  1,4% system,  0,2% interrupt, 94,3% idle
Mem: 1027M Active, 284M Inact, 199M Laundry, 345M Wired, 72M Free
ARC: 77M Total, 34M MFU, 30M MRU, 32K Anon, 825K Header, 12M Other
     41M Compressed, 96M Uncompressed, 2,37:1 Ratio
Swap: 4096M Total, 239M Used, 3856M Free, 5% Inuse

Next steps, buying a new battery, maybe more RAM (I only have 2G) to use it remotely and get the WiFi adapter working.