LJ299-June2019-DeepDive

Hello Again, Linux

My first MacBook was the first computer I really loved, but I wasn't happy about the idea of buying a new one. I decided it's important to live your values and to support groups that value the things you do. By Richard Mavis

After ten years of faithful service, last year the time finally came to retire my MacBook. Not many laptops last ten years—not many companies produce a machine as durable and beautiful as Apple does—but, if one was available, I was willing to invest in a machine that might last me through the next ten years. A lot has changed in ten years—for Apple, for Linux and for myself—so I started looking around.

The Situation

Prior to 2006, I had used only Windows. Around that time, there was a lot of anxiety about its upcoming successor to Windows XP, which at the time was code-named Project Longhorn. My colleagues and I all were dreading it. So, rather than go through all that trouble, I switched to Linux.

However, my first experience with Linux was not great. Although 2006 was The Year of the Linux Desktop (I saw headlines on Digg proclaiming it almost every day), I quickly learned, right after wiping my brand-new laptop's hard drive to make way for Fedora, that maybe it wasn't quite The Year of the Linux Laptop. After a desperate and miserable weekend, I finally got my wireless card working, but that initial trauma left me leery. So, about a year later, when I decided to quit my job and try the digital nomad freelance thing, I bought a MacBook. A day spent hunting down driver files or recompiling my kernel was a day not making money. I needed the assurance and convenience Apple was selling. And it proved a great investment.

During the next decade, I dabbled with Linux. Every year seemed to be The Year of the Linux Desktop—the real one, at last—so on my desktop at work (freelancing wasn't fun for long), I installed Ubuntu, then Debian, then FreeBSD. An article in this journal introduced me to tiling window managers in general and DWM in particular. The first time I felt something like disappointment with my MacBook was after using DWM on Debian for the first time.

Through the years, as my MacBook's hardware failures became increasingly inconvenient, and as my personal preference in software shifted from big beautiful graphical applications to small command-line programs, Linux started to look much more appealing. And, Linux's hardware compatibility had expanded—companies had even started selling laptops with Linux already installed—so I felt reasonably sure I wouldn't need to waste another weekend struggling with a broken wireless connection or risk frying my monitor with a misconfigured Xorg.conf.

So I looked at Dells and ThinkPads, but Apple's hardware had spoiled me. I wanted a machine that felt sturdy, that worked reliably, that looked elegant and cool, that maybe I could service and upgrade myself, and that might last me another decade. Nothing I found quite hit that sweet spot. System76 came the closest, and I almost bought one, but then a colleague suggested I look into Purism. I fell in love and bought a Librem 13. It's been so great.

So, here's what I'm using now.

The Hardware

I get the impression that inspiring assurance—both in the stability and reliability of the machine and in its handling of your data and respect for your privacy—was Purism's driving design directive.

It's hands-down the nicest-feeling laptop I've ever held. Some laptops are so thin and light, they feel flimsy. The Librem does not. It's thinner and much lighter than my old MacBook, but it feels satisfyingly substantial and sturdy. Even the hinge on the screen is tight enough that, when I move the machine, it barely wobbles.

The keys press and bounce as you type and are lit from behind. The trackpad, by default, recognizes one- and two-finger clicks, and, as I'm using it now, recognizes clicks in the lower right and middle regions as right- and middle-clicks, which is quite useful in certain situations.

And, the screen has a matte finish. I wonder how I lasted for so long with a glossy screen.

Plus, it's beautiful. There are no logos on the top and no stickers on the body. The key that on other machines might show the Windows logo instead shows a thick-ish outline of a rectangle (which happens to be Purism's brand). The part of me that falls for modernist, minimalist design is very pleased with the Librem's black-box aesthetics.

Is it perfect, or even better than a MacBook in every way? Of course not. For example, along the screen's frame there are six little rubber feet that touch the base when the laptop is closed. On the MacBook, there is a thin line of rubber that runs all the way around the frame which both makes it less noticeable and, presumably, permits less dust and such when closed. Apple's MagSafe power adapter is nicer than the standard plug. And, Apple's trackpad driver seems more refined—at least it never stalls and resumes tracking only after I move my fingers in a certain way. Also, finger grease appears much more easily on the keys. On the other hand, I now clean my keyboard more often than I used to, so you could consider that more a feature than a bug. But these are small complaints. Overall, it's a superior experience. When I use my company's MacBook Air now, it feels like a regression.

It's also nice to know that when I need to service or repair it, I'll be able to manage that myself. About halfway into its life, my MacBook's hard drive died. The Apple Store told me recovery and replacement would cost more than $1,000 and take about two weeks. So I found a local data recovery specialist who did the job for half that cost in three days. I'm not sure whether Apple allows owners of their newer laptops to do that anymore.

The Software

PureOS, PureBrowser

The Librem ships with PureOS. It's based on Debian, uses GNOME 3 by default, and comes with its own custom version of Firefox called PureBrowser.

PureBrowser

Figure 1. PureBrowser Running on PureOS on a Librem 13

Apparently other distributions can run on the hardware, but I've found no reason to switch. Neither have I needed to install a different browser.

i3, st, Dunst

I have, however, switched from GNOME to i3. In the same way that my MacBook spoiled me with hardware, DWM spoiled me with window managers. And, as great as it is, I didn't switch to Linux for GNOME. A big part of the appeal was an environment that was fast and uncluttered, with less images and animations, but more keyboard- and command-line-driven, something more customizable and convenient. Something I could make my own.

Floating Window

Figure 2. i3 Showing One Floating Window

You might not be impressed with the look of my environment—I mostly just copied the Acme colors—but some people have put a lot of work into making theirs look sexy.

If you're not familiar with i3 or tiling window managers in general, there are a lot of videos out there. But the general idea is that, when you open a new window, the window manager both places and sizes it to optimize the space on your screen. So one window will occupy the full screen, two will be split evenly, and so on. There are no fancy window borders or drop shadows, no title bars or buttons to minimize or close it. Instead, there are keyboard shortcuts for opening and closing windows, collapsing them into stacked or tabbed groups, for floating and resizing them, calling custom scripts, and so on. And, you get to determine what those shortcuts are. If you want to add a hotkey to open your web browser or text editor or to lock your screen, you can do that.

Unless you specify some other program, new windows will open with your terminal emulator. For that, I'm currently using st, which is nice and fits well with this model since it doesn't contain built-in functionality for tabs and such. (Since switching back to Linux, I've learned that the Suckless group receives a lot of shade on the internet. But I respect them and their goals even if I don't use all of their products.)

One thing I wanted to see much fewer of on my machine was notifications. For the past few years, the number of notifications I'd been seeing daily seems to have accelerated wildly—notifications for upgrading, notifications offering a tour of new features, notifications I couldn't dismiss without invoking some action. I now see hardly any, and because Dunst is easy to customize, they now look great in my environment.

Dunst Notification

Figure 3. Dunst Showing Three Notifications

The switch to i3 was not completely painless. For one, the trackpad's scroll direction reverted (Apple was right to reverse it all those years ago). But fixing that was just a matter of adding one line to my ~/.Xmodmap file. And, the keys to change the screen brightness and speaker volume stopped working, but those were pretty easy to fix as well.

Keyboard Fixes

Figure 4. A Few Keyboard Fixes for i3

The experience was rewarding. It's no monumental achievement in programming, but after fixing my brightness keys, I felt like I had both learned and accomplished something. Too many issues like that would not be fun, but those were all I had. And the cost was well worth the benefit. Especially if you're any sort of developer, these kinds of small problems with easy solutions can provide valuable exposure to new ideas and unfamiliar things maybe outside your domain.

Plus, it reminds me a little bit of playing with LEGOs. If you like to tinker, Linux is great. Given all these pieces that fit together, you can adjust so many more aspects of your experience, from the aesthetics through the workflow, than you can in other systems. And if some piece you want is missing, you can make it.

dmenu (and Scripts)

Aside from Emacs, dmenu is the most versatile tool I'm using, and it's the one I miss the most when I use other systems.

dmenu is a simple program: it opens a window containing a text input area (with an optional prompt) and a list. You can filter the list by typing; you can move the selection indicator with the arrow keys, and you can select an item by pressing Enter. The selected item is returned to the process that opened dmenu. And, that's it. But its simplicity is what makes it so useful. It's an excellent example of The UNIX Philosophy in practice—it does one thing well, it works with text streams, and it works well with other programs—and it's my favorite Suckless project.

If you've never used it, here's a good video of dmenu in action.

The program dmenu_run will create a dmenu listing the executable items in your $PATH and run the one you select. This might be why dmenu is often thought of as a program launcher, but that's only one thing it can do. For example, you could use it to exit i3.

dmenu

Figure 5. A Script to Exit i3 Using dmenu

You could use it to mount and unmount drives. You could use it in a custom chain of commands, reading and filtering and piping values from a database through scripts to arbitrary applications. Or, if you'd rather just use it as a launcher but don't see yourself using it to run, say, test in that way, you could write a script limiting the options to your favorite graphical applications.

GUI Applications

Figure 6. A Script for Launching Your Favorite GUI Applications via dmenu

clipmenu

On my MacBook, I used Flycut, and I didn't want to be without a clipboard manager.

clipmenu is a clipboard manager that uses dmenu. To use it, you invoke the program, select the item you want to paste, then paste it using the standard method(s).

Pclipmenu

Figure 7. clipmenu Showing Items Filtered on "Suck"

Linux offers more methods for copying and pasting than macOS. At first, I thought this was too complicated, but I just didn't know how to use them right. macOS provides one clipboard buffer; Linux provides three. One behaves as you'd expect, but there's another (called the primary selection) that allows you to copy and paste without replacing the content in the clipboard buffer. (Apparently, there's also a secondary selection, but I have no idea how to use it yet.) The primary selection buffer stores the most recent text you've selected, and you copy it by clicking the middle-mouse button where you want to paste it. It's so convenient.

One other pain point I discovered shortly after switching back is that Linux's graphical programs use Microsoft key conventions for copying and pasting (Ctrl-C to copy, Ctrl-X to cut and Ctrl-V to paste). This is unfortunate, because the Control key is used to send signals in the shell—Ctrl-C sends the interrupt signal, which usually will either kill the program you're running or cancel the command you've typed—so there's a conflict. This means that those copy-and-paste keys can't be used consistently across the system. macOS uses C, X and V in those ways, but in combination with the Command key instead of Control, thereby avoiding this issue and enabling consistent copy-and-paste behavior in the shell and everywhere.

However, I also discovered that pressing Shift-Insert will paste the content of the clipboard buffer, and it will do so both in the GUI and the shell. So now I mostly use that. And I've bound clipmenu to Super-Insert, so it's nice and mnemonic.

But in practice, I use the clipboard much less often now thanks both to the primary selection and a little tool I wrote: Something Like The Plumber.

Often I'll copy and paste some text, not because I want to move it around a document, but because I want to act on it—like when copying a URL from an email into the browser. This isn't always ideal. For example, to look up a word in the Oxford English Dictionary, that requires selecting the word, copying it, switching to my browser, going to the OED's site, scanning the UI for the search bar, pasting in the word, submitting the form, and finally, landing on the page that contains the definition. That's too many steps. It'd be better if I could just pipe the word to the website and see the result page.

So, taking inspiration from Plan 9's Plumber, I wrote a loose and simple system that enables a cheap imitation. It enables you to select some text, invoke the plumber, select the script that should receive the text, and then do whatever you want with it—like pipe a word straight to your favorite dictionary.

Imitation of Plan 9's Plumber

Figure 8. A Cheap Imitation of Plan 9's Plumber

cmus

For music, I'm using cmus. It's a big change from iTunes and in mostly good ways. For one, it's fast and isn't also a store. On the other hand, I miss seeing album art sometimes. And, I still haven't found a metadata editor I love. Maybe I'll write one.

cmus

Figure 9. cmus

sxiv, mupdf

For viewing images and PDFs, I'm using sxiv and mupdf. Both are simple, keyboard-controlled, fast and easy to use.

sxiv and mupdf

Figure 10. sxiv and mupdf

sxiv has a cool feature: you can call custom external commands via custom keyboard shortcuts. So, for example, if you have scripts for resizing or rotating images, in sxiv's thumbnail mode, you can select the images on which you want to act, call the script via a hotkey you define, reload the images (by pressing R), and see the results right away.

Emacs

Emacs is to text editing what a web browser is to viewing HTML. I've been using it for about 12 years. The more I learn about it, the more I love it.

Emacs

Figure 11. Emacs

One thing that initially struck me as strange about the Librem's keyboard is an asymmetry: there's only one Super key, on the left side, and in what might be its partner's place on the right is a Menu key. To my knowledge, I've never had a keyboard with this key, but Emacs interprets it as M-x, which it uses to prefix many commands. This a very handy convenience.

isync and Notmuch

isync is a program for syncing mailboxes. It's easy to configure and quick to run, but that's all it does. For organizing, searching, viewing and writing email, I'm using Notmuch in Emacs. The pleasure of writing, sending and viewing email in a text editor instead of a web browser really can't be overstated. And to coordinate isync and Notmuch, I run a script.

A Few Utilities:

About the Author

Richard Mavis spends most of his day writing code and other things. He once literally put his wife to sleep explaining what he does. You can find him via his website or Twitter.