GoodLinks, Shortcuts and a Kindle

I’ve been a huge fan of read later services for years, starting out with Instapaper way back in the Marco days, trying out Pocket, and even giving Safari Reading List an honest go once or twice. The entire category of app seemed to flourish, and then fade into mediocrity over the past few years. Lately however, I’ve been using the incredible GoodLinks 2.0 and I’m very, very impressed. Voorhees over at MacStories has the definitive review, but for my two cents - the platform native design, ease of use and deep extensibility instantly won me over.

The Problem

I’ve also been doing a lot more long form reading lately, and have been loving my Kindle for this. I adore having shelves full of books, but absolutely hate carrying around a physical tome. I found myself leaning towards reading books rather than catching up on my ever-growing list of articles sitting in GoodLinks, and thought surely there must be some way to recreate the “Kindle Experience” for my back catalog of saved items.

Once a week this shortcut triggers on my Mac automatically. It gathers the past 7 days worth of articles from GoodLinks, exports them as markdown and then combines them all into a single .epub file with a nice simple table of contents, and finally emails the epub to my kindle. I’ll step through it shortly, but let me tell you that this is easily the nicest way to catch up on a week of tabs.

How it works

First off, we run a shell script to remove last weeks digest, and set up the temp files.


SHORTCUTS_DIR="$HOME/Library/Mobile Documents/iCloud~is~workflow~my~workflows/Documents"

# Force delete old versions
rm -f "$SHORTCUTS_DIR/temp_digest.md"
rm -f "$SHORTCUTS_DIR/Weekly_Digest.epub"

# Start the file with a clear text header (No dashes!)
echo "% Weekly Digest" > "$SHORTCUTS_DIR/temp_digest.md"
echo "% Generated on $(date)" >> "$SHORTCUTS_DIR/temp_digest.md"
echo "" >> "$SHORTCUTS_DIR/temp_digest.md"

This directory “$HOME/Library/MobileDocuments/iCloud~is~workflow~my~workflows/Documents”, is a really interesting hangover from the Workflow days, before the team was acquired by Apple and became the foundation of Siri Shortcuts

Next, we use some of GoodLinks excellent shortcut actions to:

  1. Find Link where: Date Saved is in the last one week
  2. Then within a loop, grab the article content of each Link

One more shell script is triggered to use Pandoc to take these markdown files and combine them into a semi-professional looking epub for Kindle consumption.

export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"

SHORTCUTS_DIR="$HOME/Library/Mobile Documents/iCloud~is~workflow~my~workflows/Documents"
INPUT="$SHORTCUTS_DIR/temp_digest.md"
OUTPUT="$SHORTCUTS_DIR/Weekly_Digest.epub"

# --epub-chapter-level=1: Forces a physical file split at every # Header.
# This is the most reliable way to fix TOC positioning.
pandoc "$INPUT" \
    -f markdown-yaml_metadata_block \
    -o "$OUTPUT" \
    --toc \
    --toc-depth=1 \
    --epub-chapter-level=1 \
    -M toc-title="Table of Contents" \
    --metadata title="Weekly Digest" \
    --standalone

Finally, pass this file as an attachment to a new email to your kindle (instructions to find your kindles email address here). Once processed by Amazon, the weekly digest should show up on your device within a couple of minutes.

The shortcut in complete is available here, just make sure to add your Kindle email address into the final block, or else nothing will happen.