Hacker News new | ask | show | jobs
by steelframe 1381 days ago
For me at least, the medium matters. If the content is on a device where it is trivial to switch away to something else that could potentially be more "rewarding" to my brain, then every portion of said content must compete with everything else available to me on said device. If the content needs to lay some tedious groundwork to build up to something great, then on certain devices I have to fight through the urge to "flip away" to something else or skip over that part of the content, potentially compromising how I experience the content as a whole.

This is why I recently spent some time to hack up a script to extract news stories into PDFs that I transfer onto an e-reader. I have a subscription to a news site, but I find it's just easier to just use a paywall bypass extension rather than log in when my cookie expires every day or so. I wrote a Python script to pull down the RSS feed for my news site, and with the modules html5_parser, lxml.etree, asyncio, pyppeteer, and slugify, in about 60 lines of code I've got something that displays the headlines one at a time in a console. Based on the headlines, I hit 'y' if I want to read it or 'n' to skip. It uses pyppeteer to fire up a recent build of Chromium, which runs in non-headless (headful?) mode in order to run extensions while still supporting print-to-PDF (patch for that landed July 22nd, hence the recent build to get it). I use xvfb so the Chromium window doesn't pop up on my window manager. Even though I pay for a subscription the news site still displays ads, so I block those with PiHole and the uBlock Origin extension.

I have scripts to detect which /dev file my e-reader gets and to mount it. Then I print-to-PDF the news articles I want to read, saving to the e-reader. On quitting the script, it unmounts. I can grab the e-reader, find a cozy place away from my phones and tablets, and read through the articles without ads, animations, or other distractions, and without the ability to "flip away" to something else on the device I'm using.

Of course all this took me the better part of a Saturday afternoon to get working as I slogged through all the hurdles -- print-to-PDF wasn't working in headful mode, but I needed headful mode to use the paywall-bypass and adblock extensions (solution: found the patch to get print-to-PDF work in headful mode happened in late July). The e-reader doesn't always get the same device file (solution: seek back in /var/log/messages to find the logs for my e-reader and use re package to pull out the device name). I couldn't figure out how to get asynchio to immediately fire off a thread when I hit 'y' on an article and didn't want to wait for a gather() on a bunch of tasks at the end of selecting articles, so I created my own threads and fired up my own event loops for asynchio to use, which is required for pyppeteer. Font was too small on my e-reader (solution: use 'scale': 1.5 in the page.pdf() parameters for pyppeteer). Finally I had to deal with the headful Chromium windows popping up and taking focus (solution: wrapper script to launch Chromium using xvfb-run).

Of course this sort of thing is a lot more labored than just defaulting to clicking links in a web browser on the phone. But by now I feel that the environment is toxic to my ability to concentrate and avoid obnoxious content like animated ads, so it was worth it to me to spend a few hours to figure out how to shift the content onto a device that supports putting real time and attention into content intentionally selected.

I plan on adapting this to pulling down other websites to my e-reader since there's nothing magic about my news site. Anything with RSS could theoretically work; I'd just need to tweak my parsing of the feed depending on its organization. And I'm certain there is an OSS solution that already does what I hacked together but in a smarter or more robust way.