Switched blog to static using Hexo

In a general attempt to somewhat “degoogling” my life, I have moved this blog from Blogspot (which has been Google-owned for a while now) to my own, private web site.

To this end, I am using the Node.js-based static site generator Hexo and feel like I am its only non-Japanese user in existence. Thankfully however, most of the documentation is also available in English and help plentiful on Github forums and the like. So far, so good.

In other news, I have also completely banned all closed-source Google applications from my mobile, which is now running Lineage OS 14.1 and the F-Droid rather than the Google-Play store. Camera uploads end up in NextCloud, operated by a close relative of mine, and navigation needs are satisifed by the open-source program OsmAnd. I also learned that the freely available mail client K9 is nowhere near as immature as it was 10 years ago, when I had tried it last. To cut a long story short: I am not missing a thing, have regained full control over my personal data, and the device’s battery life has just doubled since there is now bugger-all background activity going on when compared to previously. I am surprised, what took me so long…

Lineage OS 14.1 on my LG G2 D802 (intl) - using only open source software

Finally, a technical task that warrants for transcription in my long neglected blog: I’ve updated my LG G2 from CM11 to LOS 14.1 over the last day or so. It was surprisingly painful, given the large number of tutorials online. Hence I want to point out why exactly this was the case. Though, be warned: this is not intended as a step-by-step tutorial or what not! I’m merely pointing out some caveats in the process, which you should be more or less familiar with, when you attempt anything like that. I will take no responsibility for any harm you, dear reader, might cause to your phone.

  1. Rooting: I am on Linux. I can’t start off by downloading the LG Flash Tool or anything like that. Instead, I rooted my device using a shell script wrapper around the adb tool, called ioroot.sh. VERY IMPORTANT: before you call it, replace SLEEP with sleep and ./adblinux with adb. Especially if you forget the SLEEP part, you will no longer be able to boot, not even into recovery. Your only choice then is to find above mentioned Windows tool and reflash a stock image from the net somewhere using the phone’s download mode. (That happened to me back when I switched from LG’s original image to CM11.)

  2. Bootloader: If you follow the tutorials on rooting, using ioroot.sh, you’ll end up either with the CWM or TWRP bootloader. My observation: TWRP seems to be where it’s at today. However, you’ll end up with a version 2.6, while the official project’s sources are at 2.8 and patched versions floating the net are 3.2.1. To cut a long story short: TWRP 2.6 is absolutely useless for getting a recent CM/LOS zip installed.

More so, I was not even able to install 3.2.1 with it, until I patched the existing 2.6 with what is known as the “loki exploit”. While loki is no longer needed (or even supported) for 3.2.1, it seems, that in 2.6 you cannot install anything rather recent without it. This wasn’t obvious to me and installation somewhat painful, because what the Lineage OS install page says seems wrong: you cannot simply dd an image of TWRP 3.2.1 to /dev/block/.../by-name/recovery or anything like that but have to do as I said: patch 2.6, and then do an ordinary install of 3.2.1 using the patched 2.6.

  1. Bootstack: Also, it turns out, the official Lineage OS documentation didn’t mention either that if you’re coming from a very old version of Android/CM/LOS, as I did, you’ll need to install a new bootstack first. This is the scariest part of the process, as failing to apply the right file will definitely brick your device!

The right bootstack for the D802 seems to be the hybrid one that’s widely available on github. The zip can be installed as normal using the now installed TWRP 3.2.1 and the phone rebooted afterwards.

  1. Lineage OS 14.1: If your device isn’t bricked at this point, it is now possible to adb push a Lineage OS 14.1 zip onto /sdcard, wipe everything except internal storage, and then install it. Afterwards, it is necessary to wipe cache/dalvik clean and install the appropriate OpenGapps for the right device and LOS revision, and then reboot again.

Another very important point in this regard: After step 3., the key combination to enter recovery mode will have changed! Before, one had to hold down Vol-Down + Power on a switched-off phone until the LG-logo would pop up, let go of the buttons, and then press them again until the factory reset would appear. With a new bootstack, one has to initially press Vol-Down + Power, let go, and then press Vol-Up + Vol-Down until the factory reset appears! Very important to know that!

As I said, the whole update process isn’t exactly straightforward and bears the potential to brick the device, but the good news is: it helped me get Android 7.1.2 on my trusty old G2, and I expect that future updates to Android 8 will now only require entering the recovery mode, and then installing a new LOS-zip and GApps without further bootloader, bootstack, etc. patching.

Firefox/Iceweasel slow on a D-Link router? Read on...

I previously complained that my Firefox/Iceweasel browser has become unbearably slow, in that it sometimes loads pages, and sometimes stops right in the process. It looks like some kind of DNS issue, except that DNS works fine, and so do other browsers. For months I have been looking for all kinds of fixes to this issue, disabled ipv6 in Firefox, even for my network, but to no avail.

However, I always suspected it had to do with ipv6, or rather how my router handled it, I just couldn’t nail it down. Moreover, Mozilla forums couldn’t provide a solution either. Most people suggested Firefox plugins, such as AdBlockPlus, are to blame for browser sluggishness.

Anyway, while I had already switched to Google Chrome, which didn’t suffer from these issues, I kept my eyes open for a solution as it always bugged me that I couldn’t find out what was going on. And, indeed, getipv6.info not only can explain the problems I had, but also provide a really simple fix. So let me re-distribute this valuable piece of information via this blog here, so that other users, who are in the same boat, will be able to find it more easily:

Several D-Link models from the DSL series (at least DSL-584T, DSL-G604T, DSL-G624T, DSL-G664T, and DSL-G684T), do not correctly forward DNS responses for hostnames with both A and AAAA records published. What it does is to stuff the first 32 bits of the AAAA record into the A record that’s being returned to the end user’s computer. In other words, getipv6.info will incorrectly resolve to 32.1.5.0 (the 2001:0500: part of the IPv6 address). If the operating system or web browser prefers to use IPv4, it will be unable to connect to the destination. Italian ISP Wind/Infostrada is reported to have distributed the DSL-G624T to its customer base over a period of several years.

It doesn’t happen all the time - it appears to be timing-dependent. Older Mozilla Firefox browsers are hit particularly bad, due to the fact that they will request AAAA lookups even if the local host does not have an IPv6 address. Work-around: Disable DNS forwarding support in the router. This will cause the D-Link to advertise the ISP’s upstream DNS resolvers (instead of itself) in DHCPv4, and the hosts on the LAN will query them directly.

For the record: I own a D-Link DIR-632, running on firmware 1.02. The above, indeed, made Firefox work like a charm again. (Having said that, nothing’s going to make me switch from Conkeror back to Firefox again. ;-)

Conkeror - a browser that doesn't suck

Switching web browsers, these days, is like a life changing experience for the better or the worse, akin to moving flats or changing jobs, perhaps. Well, maybe that’s an exaggeration, but it’s certainly as earth shattering as changing window manager (and I’ve been there, changed from FVWM to awesome after more than ten years).

So yesterday I switched from Google Chrome to Conkeror, and couldn’t be happier. Before that I was a fairly happy Firefox/Iceweasel customer who loved his vimperator plugin. For the uninitiated, vimperator, basically, lets you operate Firefox almost mouseless. It’s awesome to state it with an americanism.

However, lately Firefox didn’t work for me anymore, pages stopped loading or wouldn’t even open, akin to having DNS problems - except that I didn’t. After a bit of web searching, I found out it could be (and probably is) ipv6 related, in that Firefox by default first attempts an ipv6 connection before it falls back to ipv4, if ipv6 is not supported for whatever reason. Turns out you can disable this behaviour in Firefox, and you can permanently rid Linux of ipv6 support, except that neither solved the problem for me. After several weeks, I had to give in and switch to another browser, Chrome, as my hands were hurting from pressing reload on every page. Chrome worked fine, is fast, but lacks an equivalent to vimperator. Those plugins that do exist are nowhere near as customisable. So this browser change, was not very earth shattering at all, in fact, not even anticipated and never liked.

But the lack of keyboard support for Chrome also annoyed me, to the extent of trying one of the most seemingly archaic web browsers out there: Conkeror. In a nutsell, Conkeror is the emacs (or vim?) among the browsers. No menu bar, no tabs, no nothing. Just keyboard shortcuts and endless possibilities for configuration. At first, I was afraid I’d need to spend another week learning it, but after 30 min or so, I had a config which more or less resembled the behaviour of my previous vimperator setting, and couldn’t be happier. I’ve finally found a browser that doesn’t suck balls!

Since $HOME/.conkerorrc files are still somewhat hard to come by in the world wide web, I’ve decided, also to mark the occasion, to post my 30 min version here:

// auto completion in the minibuffer
minibuffer_auto_complete_default = true;
url_completion_use_history = true; // should work since bf05c87405
url_completion_use_bookmarks = true;

// we don't need a clock
remove_hook("mode_line_hook", mode_line_adder(clock_widget));

// Tabs
require("new-tabs.js");

// Open Middle-Clicked Links in New Buffers
require("clicks-in-new-buffer.js");
clicks_in_new_buffer_target = OPEN_NEW_BUFFER_BACKGROUND; // Now buffers open in background.

// Bind Number Keys to Switch to Buffers 1-10
function define_switch_buffer_key (key, buf_num) {
    define_key(default_global_keymap, key,
               function (I) {
                   switch_to_buffer(I.window,
                                    I.window.buffers.get_buffer(buf_num));
               });
}
for (let i = 0; i < 10; ++i) {
    define_switch_buffer_key(String((i+1)%10), i);
}

// Some shortcuts to often used sites
interactive("open-googleAU", "Go to google.com.au", "follow", $browser_object = "http://www.google.com.au/");
interactive("open-googleDE", "Go to google.de", "follow", $browser_object = "http://www.google.de/");
interactive("open-calendar", "Go to calendar.google.com", "follow", $browser_object = "http://calendar.google.com/");

// Some keybindings

define_key(content_buffer_normal_keymap, "j", "follow");
define_key(content_buffer_normal_keymap, "J", "follow-new-buffer-background");
define_key(content_buffer_normal_keymap, 'b', 'back');
define_key(content_buffer_normal_keymap, 'f', 'forward');
define_key(content_buffer_normal_keymap, "C-page_up", "buffer-previous");
define_key(content_buffer_normal_keymap, "C-page_down", "buffer-next");
define_key(content_buffer_normal_keymap, "C-x k", "kill-current-buffer");
define_key(content_buffer_normal_keymap, "C-x l", "find-url");
define_key(content_buffer_normal_keymap, "C-x t", "find-url-new-buffer");
define_key(content_buffer_normal_keymap, "A", "bookmark");
define_key(content_buffer_normal_keymap, "B", "list-bookmarks");
define_key(content_buffer_normal_keymap, "f1", "open-googleAU");
define_key(content_buffer_normal_keymap, "f2", "open-googleDE");
define_key(content_buffer_normal_keymap, "f3", "open-calendar");
define_key(content_buffer_normal_keymap, "C-x h", "open-googleAU");
define_key(content_buffer_normal_keymap, 'v', 'view-source');

// Some webjumps
define_webjump("dict", "http://dict.leo.org/ende?lp=ende&lang=en&searchLoc=0&cmpType=relaxed&sectHdr=on&spellToler=&search=%s");
define_webjump("g",   "http://www.google.com.au/search?q=%s");

// Content handlers
external_content_handlers.set("application/pdf", "mupdf");

Conkeror is not only great because it does exactly what I tell it to do, but also it has a lot of sane standard behaviour which needs no configuration. For example, when I open a PDF file - and boy do I open a lot of PDFs all the time - it first asks me if I want to download or view. If I download, everything works as expected. However, if I decide to view, the status bar changes into the default viewer command, which I can either confirm by pressing enter, or replace by typing the name of some other browser. That’s the fastest way I’ve ever seen to switch PDF viewers, which I also tend to do multiple times every day. (And no, I do not want to select a viewer from a drop-down menu using the mouse all the time.)

Conkeror makes web browsing the painless experience it should be and I can only urge you to give it a go. Oh, and most importantly, so far it also doesn’t suffer from the random page-load problems that I experienced with Firefox.

Turning off antialiasing for specific fonts only

I like antialiased fonts for many things, such as web surfing or reading on my iPad, in fact, I could not imagine reading on the iPad without antialiasing. However, one application where the invent of antialiased fonts has always bugged me is text editors for programming. This is perhaps a relic of the past as I grew up with pixelated editor fonts, or simply because I use pixelated fonts for working on the console. I’m not actually sure myself.

To cut a long story short: I’ve been trying to tell emacs for quite some time to disable antialiased fonts, but to no avail. Apparently in Aqua-emacs on the Macintosh, one can set a flag in the emacs preferences, which is not available under Linux. The reason, apparently, is that emacs doesn’t really do much in terms of font handling on Linux and uses pretty much what X, or rather X’s font server provides it with.

Today, I found a solution to my dilemma, which I think makes a neat first post on this blog. Most Linux distributions will use a file called fonts.conf which is either located in /etc/fonts or under the name .fonts.conf inside a user’s home directory. (A good way to get a useful .fonts.conf is to copy the one from /etc/fonts to $HOME/.fonts.conf.) Inside this file, you need to add something along the lines of

<match target="pattern" name="family">
    <test name="family" qual="any"><string>Envy Code R</string></test>
    <edit name="antialias" mode="assign">
        <bool>false</bool>
    </edit>
</match>

This turns off antialising for the Envy Code R programming font, but ensures that other fonts remain antialiased (if antialising was the default behaviour before, otherwise you need to add a statement to enable it). So you get the best of both worlds, sharp, readable fonts in emacs, and polished fonts in your browser. Note that there are quite a number of fonts, specifically designed for programming, such as ProFont or Proggy, which are unusable when antialiased.

To see the result of the above addition to the configuration file, take a look at this screenshot which features a pixelated programming font Envy Code R in the left frame, and an antialised Arial in the right: