Rocking Dual-Framebuffers with Linux

Mon 11 November 2013

I’m a long-time user of desktop Linux, and one of the big reasons I like it is that it allows you to use hardware that is typically considered ‘obsolete’. So much hardware is needlessly thrown away because it doesn’t run the latest Windows, but that doesn’t mean you can’t squeeze another 4-5 years out of that hardware. However, since the disastrous introduction of Gnome 3.0, graphics usage has become increasingly resource-heavy in Fedora. While there are several "thinner" desktops out there (XFCE is a good example), you can always go lighter. So when my home workstation couldn’t load X windows upon upgrading to Fedora 19, rather than switch to a lighter desktop, I decided to eschew X windows altogether. The odd thing is, once you walk away from X, you might be surprised at how capable your machine still is.

Hit Me With That Black Magic

Once I used dual screens, I couldn’t go back. I like having multiple tmux sessions on both screens, and so simply dropping X wasn’t all that hard. However, X typically deals with the multiple outputs, so dropping it means using a bit of trickery to get two independent consoles.

First download ‘fbset’. This is good for troubleshooting, and will help you if you have resolution issues.

Next, you’ll need to have 2 Linux framebuffers. This is /dev/fb{x}, which you probably never noticed until now. I think it’s possible to get two framebuffers off a dual-head card (X does this, IIRC), but frankly, I got lazy and used a spare card that I had lying around. The beauty of using the console means I didn’t need anything powerful, just something that can spit out text.

Now where the fun starts is using con2fb. Compile ‘con2fb.c‘ and then run ‘con2fb /dev/fb1 /dev/tty2’. This ties a tty to your second framebuffer, allowing you to keyboard-switch between the two monitors with alt-ctrl-F2. For quick tty cycling using the alt key, disable the GDM service with systemctl disable gdm.service.

To have your Fedora machine boot up and run con2fb at boot, just put it in /etc/rc.d/rc.local (make it executable). This file doesn’t exist by default, because the systemd folks feel it’s bad practice. Screw them, it’s your damn machine.

You’re close to perfect, but one thing I found when playing cmus is that switching tty’s suspends playback. The pulse developers know about this, and expect us to be happy that it does this. Screw them, it’s your damn machine.

Run yum remove pulseaudio alsa-plugins-pulseaudio and use ALSA like a boss. If you’re using cmus, don’t forget to set output_plugin to ‘alsa’ and mixer.alsa.device to ‘default’ (or whichever ALSA device you want to use).

Now you should have a lean machine that runs well even in limited resources. The longer you work outside of X, the more handy tools you’ll find to do your work much faster. Absolutely worth it.

Update: April 2014

The hardware that was running this has long since died, so I’m no longer running this setup. I’ve gotten a few email about about the bug where when you switch from one monitor to another, the old monitor does not refresh. I used tmux in this setup quite heavily (one monitor as ‘reference’, the other as ‘active’), and so for 99% of the time this was simply not a problem for me. I think it should be possible to fix this bug, but I’ve no longer got a reason to fix it. If you do, email me the patch and I’ll put it up!