Hull Zero Three

Hull Zero Three cover

by Greg Bear, 2010

A smashing hard SF tale, about the existential mystery of life aboard a generation starship that has lost its way. Following in the footsteps of classic variations, such as Non-Stop, Methusalah's Children, and Tau Zero, it centers around the character's revelations as they uncover their situation and origins, being decanted to order by warring factions amongst high technology ruins.


Station Eleven

Station Eleven cover

by Emily St. John Mendel, 2014

An evocative tale of intertwined lives, before and after the sudden fall of contemporary civilisation due to a global pandemic.


Installing Colout

Colout is amazing, I use it all the time.

But pip install colout from PyPI is broken, and has been for many months, due to a typo in the latest (v0.5) PyPI release.

I've tried to contact the author, with email and issues on the Colout Github project.

This has had no effect, although I see the author has made substantial commits to the Github project in that time, including fixing this problem and tagging a new v0.6 version, although has not released any of that to PyPI.

So, in increasing order of desirability, you can either:

Clone the latest repo from Github, and install from that:

# cd to the clone, then
python3 -m pip install --user .

Or, pip install the version I uploaded to PyPI, which is a straight copy of the latest Github at the time:

pip install --user colout-fix

Or, best of all, pip install straight from the original Github repo:

pip install --user git+git://github.com/nojhan/colout.git

Note that, throughout, we're using --user, so that you can install development tools like this system-wide for the current user, without needing a virtualenv, without needing root access, and without modifying your installed Python system libraries.

Running Multiple Firefox Profiles on Linux

I recently switched from Chrome to Firefox. It's so fast, and easier to trust that Mozilla has my privacy and interests at heart than Google does.

I want to run a second profile at work, to keep a distinct set of open tabs, bookmarks, and the like. Here's how I did it:

Close all Firefox windows. Run the Profile Manager with firefox -p. Create a second profile.

Open Firefox and find the directories your profiles live by browsing to about:profiles.

Substitute those directories into this firefox.desktop file, where I've marked 'XXX':

# Gnome3 .desktop file for Firefox with multiple profiles
[Desktop Entry]
Version=1.0
Name=Firefox
Comment=Browse the web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Type=Application
Exec=firefox --no-remote %u
Terminal=false
X-MultipleArgs=false
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
Actions=home;work
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true

[Desktop Action home]
Name=Firefox (home)
Exec=firefox --profile .mozilla/firefox/XXX --no-remote %u

[Desktop Action work]
Name=Firefox (work)
Exec=firefox --profile .mozilla/firefox/XXX --no-remote %u

Save the above as firefox.desktop and install using:

$ desktop-file-validate firefox.desktop
$ desktop-file-install --dir=.local/share/applications firefox.desktop

This results in a Firefox icon in your applications menu that defaults to whichever profile you mark as default in the ProfileManager, but right clicking lets you select the home or work profile explicitly. Open each, and change the theme in one of them so the windows are visually distinct.

Tested on Ubuntu, RHEL 7.3, probably works on all Gnome3 desktops.

Automate Gnome keybindings

Sick of manual GUI twiddling to fix inconsistent keybindings on various computers. Solved once and for all, by a new script in my personal workstation setup bucket:

Warning: This:

  • works great on RHEL,
  • doesn't all work on Ubuntu<=17.04, I suspect because Unity has it's own set of keybinds that are defined elsewhere.
  • works great on Ubuntu 17.10. especially if you go in manually to disable the built-in keybinding for Super-V, which displays the calendar and notifications window, which shadows my 'toggle window maximize vertically'.
#!/usr/bin/env bash

kb='org.gnome.desktop.wm.keybindings'

# Switcher, between windows not apps, uses alt-tab and alt-grave
gsettings set $kb switch-windows "['Tab']"
gsettings set $kb switch-windows-backward "['grave', 'Tab']"
gsettings set $kb switch-applications "[]"
gsettings set $kb switch-applications-backward "[]"

# Window maximize toggle, super-up
gsettings set $kb maximize "[]"
gsettings set $kb toggle-maximized "['Up']"

# Window maximize vertically toggle, super-v
gsettings set $kb maximize-vertically "['v']"

# run command, super-r
gsettings set $kb panel-run-dialog "['r', 'F2']"


# Custom commands

mk='org.gnome.settings-daemon.plugins.media-keys'
ckb='/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings'

gsettings set $mk custom-keybindings "['$ckb/custom0/', '$ckb/custom1/']"

gsettings set $mk.custom-keybinding:$ckb/custom0/ name "screen off"
gsettings set $mk.custom-keybinding:$ckb/custom0/ command "screenoff"
gsettings set $mk.custom-keybinding:$ckb/custom0/ binding "z"

gsettings set $mk.custom-keybinding:$ckb/custom1/ name "terminal"
gsettings set $mk.custom-keybinding:$ckb/custom1/ command "terminal"
gsettings set $mk.custom-keybinding:$ckb/custom1/ binding "t"

Embedded in that is the ultimate solution to my longstanding irk with Unity and Gnome's default window switcher (alt-tab.) By default it groups windows of a single application together, requiring some extra -grave pressing to navigate between windows within an application.

This not only requires way more effort, but also breaks the expected behaviour of just tapping alt-tab to go back to the last used window. Instead it goes back to the last used application, so you can't toggle between two windows of the same application, eg. two terminals. Absolute madness.

The above modifies alt-tab to just cycle through all windows, ungrouped, which fixes the ability to toggle between last two windows. Also, alt-grave is provided as an alternative to cycle backwards through the windows, which is easier to hit than shift-alt-tab.

Postscript formatted man pages

man and its troff formatting can be asked to produce postscript output. Define a Bash function, e.g. in your .bashrc:

function psman () {
    SLUG=$(echo $@ | tr ' ' '-')
    FNAME="/tmp/man-$SLUG.pdf"
    set -o pipefail
    man -t "$@" | ps2pdf - "$FNAME" && \
      nohup evince "$FNAME" >/dev/null 2>/dev/null
    set +o pipefail
}

(I tried to do this without tempfiles, using process substitution, but failed. Anyone got better Bash-fu?)

The man -t is the crucial part. It tells man to produce output in postscript format, which ps2pdf can read, and evince displays the PDF. We disconnect the evince process using nohup, so that it lives on even if we kill the terminal. We `set -o pipefail` so that if `man` fails, the exit code is preserved as the exit of `man|ps2pdf`, which causes the `&&` to short-circuit, preventing evince from being run on an empty pdf document. We restore `+o pipefail` again at the end.

Then, from the command line:

$ psman tr

produces

Rhythmbox plugin: "Announce"

I use the Linux music player "Rhythmbox". This morning I wrote a plugin for it, called "Announce":

https://github.com/tartley/rhythmbox-plugin-announce

Every time a new song starts to play, it announces the title using speech synthesis. I like it when I'm listening to some new music I'm not familiar with, but am away from the computer. Then I can still know which track is which.

If the album or artist names are different from the previous track, then it includes those in the announcement, too.

Google Chrome Credit

I just noticed: Open Chrome, go to chrome://credits/, search in page, 'show licence', and:

chrome-credit

Which is nice. Not bad for a dirty weekend hack.

Git: When to use three dots vs two

I endlessly misremember when to use '...' in git versus '..'. That ends today:

To see the commits or diffs introduced by a branch (the filled circles ●):

     f
    +●  m           git log m..f
     |  ○
    +●  |           git diff m...f
      \ ○
       \|
        ○

To see the commits or diffs between the tip of one branch and another:

     f              git log m...f
    +●  m           All commits look the same,
     |  ●-          unless you use --left-right, which
    +●  |           shows where each commit comes from.
      \ ●-
       \|           git diff m..f
        ○           '-' commits are shown inverted,
                     i.e. additions as deletions.

To see the commits from 'f' back to the beginning of time:

     f
    +●  m           git log f
     |  ○
    +●  |           (diffs back to start of time are just
      \ ○            the contents of the working tree)
       \|
       +●
        |
       +●

Throughout, omitted branchname defaults to current HEAD, i.e, the one of the above that you almost always want:

git diff m...f

is the same as

git checkout f
git diff m...

or

git checkout m
git diff ...f

Is there a word for unicode ascii art?