FreeBSD Desktop on the T400

The ThinkPad T Series is one of the most popular ever, which has led to consistent hardware design and broad support for it. Although the T400 was introduced in 2008 and produced up until 2010, it is very much suited to run the latest and greatest FreeBSD–10.1 in the current case. Here are the steps that led to a viable desktop installation using the i3 window manager, background info and a few security tips sprinkled on top.

FreeBSD Desktop on the T400 with xdm(1)

A Cautionary Tale

You can skip right ahead if you want, but I want to add a few things FreeBSD desktop experience. The tutorial is pretty simple and easy when you go through it. But, honestly, let’s just say it hasn’t always been this way…

Since the introduction of DRM/KMS the FreeBSD desktop struggled for a while in terms of driver support for new graphics hardware, but that was never a huge issue: for a long time it was the console driver that couldn’t cope with the new way of doing things. Once one booted a newer driver, there was no going back. Sometimes even blank screens with not much leverage to debug things. You could say these were the dark days of DRM on FreeBSD, quite literally.

With the inception of newcons, later sanely renamed to vt(8), all of this changed. DRM was anticipated and even the small things like Unicode support became available. Incidentally, that wasn’t the case with FreeBSD 10.0, which does not have vt(8) support at all. Only FreeBSD 10.1 and forward have said support, even though it is not yet enabled by default. The FreeBSD 10 series will probably continue this way, while FreeBSD 11 will have vt(8) enabled by default.

Then there was another issue that threatened the FreeBSD desktop community, namely WITH_NEW_XORG. Shattered desktop experiences left and right, workarounds, new fixes for things that weren’t broken and that broke stuff in the process. In all fairness, the work here is done and I haven’t seen an issue in 2015.

The gist of this is: things must progress and do break, but there are a vast number of dedicated individuals that really push the FreeBSD desktop forward. Their fruits are ripe to be tasted. We all thank them from the bottom of our hearts. So by all means, carry on now and have fun.

Installing FreeBSD 10.1

This is straightforward and it really doesn’t matter how you set up your system. Depending on your RAM you might consider ZFS, but beyond that feel free to use the defaults, encryption or no encryption or custom layouts.

While doing the installation, you should already create a user besides root. I recommend sticking him into the group “wheel”, so we can later use su(1) or sudo(8). After installation and boot up, you’ll see the login prompt and this is where our work begins…

Bootstrapping the Desktop

These steps should be handled by the root user until we do our first reboot. There are a couple of security advisories available for 10.1, so the first thing we ought to do is grab them:

# freebsd-update fetch install

Now, before we do any editing on system files, the required packages need to be pulled in. The first invoke are the packages we need to run i3(1) and the second line are tools that you should feel free to customise: editors, terminal wrappers, security-related things, etc… When prompted, agree to the terms and conditions of pkg(8); this great little guy needs a lot of confirmation and encouragement.

# pkg install xorg i3 i3status dmenu
# pkg install sudo vim-lite

I do replace the pager on my systems e.g. for proper colouring in git(1) and having man(1) not jump out of the manual page display mode when skipping to the end of the document. To do that, edit the files /root/.profile /root/.cshrc /home/youruser/.profile /home/youruser/.cshrc and replace the pager setup occurrences of “more” with “less”. Less is more. Yep.

Next we want to get the new console driver going that makes it fun to work on the terminal using e.g. tmux(1):

# echo "kern.vty=vt" >> /boot/loader.conf

Since sudo(8) is generally a good idea, run the following to tweak the configuration file by finding the line “# %wheel ALL=(ALL) ALL” and uncommenting it. If you don’t know vi(1), go to the start of said line with the cursor keys and press “x” twice to delete the first two characters of the line. Now press “:” followed by “wq” and Enter to commit your changes:

# visudo

Last but not least we need to launch a desktop as soon as we will have finished rebooting, which is done by setting up the config file for startx(1):

# su youruser
# echo "#!/bin/sh" > ~/.xsession
# echo "exec /usr/local/bin/i3" >> ~/.xsession
# chmod +x ~/.xsession
# exit

Now it’s time for a reboot:

# reboot

Desktop Experience: Hello World!

I’m assuming all of this worked and you are back at the login prompt. Log in with your user and verify that sudo(8) is properly set up. The output should show “root” after typing your user password:

# sudo whoami

Let’s load up the desktop, shall we?

# startx

i3(1) is pretty spartan. Confirm the config file setup and pick your modifier key. Mod+Enter lets you spawn a terminal window. Mod+D launches dmenu(1). Mod+1, Mod+2, etc. switches to said desktop. Mod+F toggles fullscreen mode for the active container. Mod+Shift+E should terminate your desktop and bring you back to the console, but it may be a disabled (we will tweak the i3 config later on). Worst case open a terminal window and type:

# sudo killall i3

Notice that the console has expanded beyond 80×25 characters. This is the key to skipping the desktop for most things and simply using e.g. tmux(1) on a TTY directly, but we’ll get to that another time perhaps.

Desktop Experience: These Go To Eleven

startx(1) is pretty good, but an autostart for the desktop is not a bad thing, especially if that allows us to enjoy the larger console layouts by default. Since I do not recommend automatic logins, it’s probably a good idea to use a display manager which prompts for user credentials and then takes care of launching their individual desktop setup–pretty cool for multi-user Laptops when you want others to enjoy a less technical desktop like Gnome or MATE.

To autostart xdm(1), the file /etc/ttys needs to be edited for the line that starts with “ttyv8”, being switched from “off” to “on”:

# sudo vim /etc/ttys

Next we set up a file similar to ~/.xsession:

# echo "exec /usr/local/bin/i3" > ~/.xinitrc

Last but not least, there is a nasty console window in xdm(1) that we ought to get rid off by editing /usr/local/lib/X11/xdm/xdm-config adding comments “! ” to the following lines:

! DisplayManager._0.setup:	/usr/lib/X11/xdm/Xsetup_0
! DisplayManager._0.startup:	/usr/lib/X11/xdm/GiveConsole
! DisplayManager._0.reset:	/usr/lib/X11/xdm/TakeConsole

Time for another reboot:

# sudo reboot

Now we directly boot into the ugly xdm(1) login prompt. But fear not, you’ll get used to it. ;) But anyway, your console is still there, Ctrl+Alt+F9 is your xdm(1), F1-F8 are text consoles. This is actually the part where vt(8) is needed so that we can switch back and forth. Login is straightforward as well–do go ahead.

Desktop Experience: Safe Browsing

I do most of my work in tmux(1), so why does one need a desktop? For the occasional (and purely professional) browsing of course. To that end, Chrome is a choice. Before you can start it, it wants you to do a little tweaking with the system settings, too:

# su
# pkg install chromium
# echo "kern.ipc.shm_allow_removed=1" >> /etc/sysctl.conf
# sysctl kern.ipc.shm_allow_removed=1
# exit

Using Alt+D and typing “chr” plus Enter, you’ll have found yourself a friend for your adventures on the Internet. But wait, there’s a little more to it for safety’s sake: locking your desktop manually and automatically. Here is a simple setup:

# sudo pkg install slock xautolock

In the file ~/.i3/config you add the following:

bindsym $mod+Escape exec slock
exec xautolock -secure -time 5 -locker slock

This will add Mod+Escape as the manual lock screen method and add an automatic lock after 5 minutes of idle time. slock(1) is bluntly simple and won’t show you anything but a blank screen. Inactivity shows a black screen, typing your password shows a blue screen, hitting enter will either unlock the desktop or bring back the black screen–I think you’ll know what means what.

While there, you may want to bring back the keybinding for exiting i3(1), which is Mod+Shift+E (there is a line that’s commented out). Mod+Shift+C will reload the config file. See if Mod+Escape works, and then so will automatic locking.

Desktop Experience: You’re on Your Own Now

This is enough to get you going, exploring FreeBSD and the i3 desktop, building upon it or even replacing it completely. I hope you’ve enjoyed this as much as I have.

Before we part ways for a bit, I want to add that FreeBSD Desktop on the T400 has been a delight for me, because it’s never been so easy to set it up. Sure, you’ll have to know all these steps to get it up and running as opposed to using an OS or distribution that does all the configuring for you, but you’ll find that you’ve learned a lot about how these distributions make decisions for you, the user, and how these may not always be your favourite ones. Taking matters into your own hands can never be wrong, especially when you want to avoid bloat or simply enjoy customisation and choice beyond predefinition.

The configuration files I have used to build the system can be found on GitHub. Next article will probably turn things inside out–we’ll look into tmux(1) setups on the console and how to rebuild most of the desktop experience. Let me know in the comments if there is something else you’d like to see, e.g. setting up the audio on this beauty. Stay open. :)

3 thoughts on “FreeBSD Desktop on the T400”

  1. Nah, it’s alright. Works for most laptops anyway. It’s simply nice to see that the older hardware is still very much capable of running cutting edge software and desktops. Cheers. :)

  2. Hey

    I’m following your instructions to get i3 on my t400 with FreeBSD 10.2, and everything works well until I try to startx, where it runs into a “Fatal server error: (EE) no screens found(EE)”. Do you have any ideas of what to do? I am considering trying to install 10.1 instead. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.