Coffee plant leaves

$ clipping

The Conquest of Happiness (Bertrand Russell;Daniel C. Dennett)
- Your Highlight on page 6 | Location 79-80 | Added on Wednesday, December 13, 2017 9:26:08 AM

Men who are unhappy, like men who sleep badly, are always proud of the fact.

Reading

After a year and a half of reduced book-reading, I’ve managed to rebuild a reading habit (which is great). Thank you Kindle, thank you Seattle Public Library, thank you Libby.1

With this return of regular book-reading returned a thought that always bothered me: I like reading but I don’t remember the books I read very well.

Most of the books I read are nonfiction. While reading them, it feels like my mind is engaged, and I am keeping up with the narrative, the details, the arguments – it seems impossible that I could forget any of this. But most of the time, in less a week after finishing a book, I can only remember one or two pieces of detail and the rest is gist. Not much more.

Paper vs ebook

A lot of people who read books agonize over this. You’ve probably read the same dilemma recounted by a hundred other readers.

Paper books are romantic objects. They have cultural energy, and they become objects that mean a lot more than just the words you can read within them. Second-hand book shops are magical and intimate. They always feel like sanctuaries staged in a better time. You look at a shelf, or a stack that’s too precarious, pull a book out from the middle, and if you walk out with it, that’s your special book. It’s your special piece from that magical place.

Also. A paper book has a visible cover, and a visible cover lets you show other people on the train what you’re reading. The people want their social signaling. We’re starved for a social connection, and if someone notices the cover of the book I’m reading, and we make a connection because of it, that’s a nice thing.2

The relative benefits of ebooks are apparent: you can carry many books on a device smaller and lighter than a single book, and you get search, highlighting, and typed notes.

Kindle highlights

My reading revival happened on Kindle. I love paper books (see above for an explanation that reads a little bit like a eulogy), but the Kindle is lighter, easier to hold in one hand, lets me borrow books from the library without having to go to the library, and most importantly for this post, saves my highlights locally even after the book is returned to the library.

Kindle highlights are saved to a My Clippings.txt file on the device itself.3 The file’s formatting has remained consistent for years. Here is a sample:

==========
In This Arab Time: The Pursuit of Deliverance (Fouad Ajami)
- Highlight on Page 33 | Loc. 551-52  | Added on Monday, December 15, 2014, 06:00 AM

Tahrir Square had transfixed us all, but as the immensely talented young Egyptian intellectual Samuel Tadros puts it, Tahrir Square was not Cairo and Cairo was not Egypt. 
==========
In This Arab Time: The Pursuit of Deliverance (Fouad Ajami)
- Highlight on Page 36 | Loc. 581-83  | Added on Monday, December 15, 2014, 06:04 AM

The group may have railed against America and the shadow it cast over Egypt, but leading technocrats from the Brotherhood, Morsi among them, rose to professional success and prominence through American degrees, and their years in America took them beyond the cloistered world from which they hailed. 
==========
In This Arab Time: The Pursuit of Deliverance (Fouad Ajami)
- Highlight on Page 37 | Loc. 602-5  | Added on Monday, December 15, 2014, 06:06 AM

The Brotherhood had not reinvented this weary land. Egyptian governments had long perfected the art of playing cat and mouse with the IMF and with foreign donors, mixing dependence and defiance, at once needy but proud and brittle. Like riverboat gamblers, Egypt’s rulers seem to relish the game, secure in the knowledge that a country of 80 million people at the crossroads of so vital a region, so near to the oil fields of the Arabian Peninsula and the Gulf, a Sunni balance to Iran, will always be bailed out, that it is too big to fail. 
==========
In This Arab Time: The Pursuit of Deliverance (Fouad Ajami)
- Highlight on Page 38 | Loc. 612-15  | Added on Monday, December 15, 2014, 06:10 AM

The Egypt the Muslim Brotherhood had in mind was anathema to the free spirits in the land. It is perhaps a fragile hope, but this has always been a country of coffeehouses and storytellers, a people given to humor and forgiving of the follies of others. This is not stern Arabia, but a land with a vibrant street and night life, banter between the sexes, an earthiness that looks with suspicion on zealots and the “virtue” they claim to uphold. 
==========
In This Arab Time: The Pursuit of Deliverance (Fouad Ajami)
- Highlight on Page 41 | Loc. 656-57  | Added on Monday, December 15, 2014, 06:19 AM

Dictatorship rests on a measure of consent: an ordinary man obliges, and the crowd projects onto him its need for a redeemer. 
==========

We love consistent formatting! It usually means a file can be parsed without too much work.

Random highlight

I wonder how many people make use of that clippings file. I want to be reminded of the parts of books I’ve read that I thought were worth highlighting, and an easy-to-parse clippings file means I can cut it up into separate highlights and pick a random one to read.

I thought awk would be a good tool to solve this problem. awk is a programming language (and tool?) that lets you select and process text using pretty complicated recipes. I didn’t know any awk before creating this small hack, so it’s possible that the script below is very inefficient, or even buggy. If it is, please let me know.

I put together this awk script. Let’s call it parser.awk:

BEGIN {
  clipping = "";
  i=0;
  srand();
}
{
  if ($0 !~ /==========/) {
      clipping = clipping $0 "\n";
  } else {
  clippings[i++] = clipping;
  clipping = "";
}
}
END {
  print clippings[int(rand()*i)];
}

And I created an alias that uses that script to parse my clippings file:

alias clipping='awk -f /path/to/parserk.awk /another/path/to/My\ Clippings.txt'

Which will let you run a clipping command in your terminal and get a random highlight.

Nothing is so perfect

This works nicely, but lacks polish in a few ways:

  • I have to remember to manually copy the clippings file off of the Kindle. Right now, this means connecting the Kindle to my computer, waiting for the Kindle drive to mount, going into the documents folder, and copying My Clippings.txt to its destination. This can be automated to some extent – I can automate the file copying to happen once the Kindle drive is mounted, but I’d still have to remember to connect the device itself.
  • An alias that prints a random clipping is not the best use of this file. I still need to remember to run the command, and it’s rare that what I’m most in the mental headspace for when in terminal is to read a quote from a book. What’s the alternative? I could write a script that sends me an email with a highlight every morning. Or maybe I could use some speech-to-text system and send myself an audio snippet of the quote. I wonder if I can use a text-to-speech system that sounds natural enough. I’ll have to think about it.

Misc notes

  • Use Libby, donate to your local public library.
  • If you use a Kindle, the local storage of highlights makes the utility of books you borrow using Libby even higher.
  • Being able to write scripts that solve niche problems like this is empowering. But it relies on information being available in open, easy-to-read formats like a plain text file. This is what we lose when information storage moves to proprietary formats or inaccessible locations, and that’s where the wind is blowing in some ways. I am a little surprised – pleasantly! – that Kindle still stores these highlights in the same file format it did when I saved my first highlight back in 2012.
  • Easy open formats are not perfect. One downside of the plain text file is that rich formatting like bold and italics is lost. Kindle could decide to put the work in to add Markdown markup to preserve some of that, but that adds complexity and room for what programmers like to call a “big mess”.
  1. Libby lets you borrow ebooks and audiobooks from your local public library in the US. It’s one of the best made apps I’ve used, and the one that has changed my life the most in the past twelve months. ↩︎

  2. I was on the Seattle light rail reading my copy of Issue 7 of Logic magazine, and I looked up and caught the eyes of someone else with the same issue in their hands. It made my day. ↩︎

  3. That space in the filename bothers me. ↩︎