How to use alternative settings for URxvt

Ever since I retired my HTPC I have been using my desktop computer as my HTPC with my TV connected to it. My HTPC consisted (and still) does of some terminal emulator running software like Newsboat and Ranger, but because I want to be able to read the text on the TV from the distance of my sofa I have up until now been lazy and used a secondary terminal emulator with alteranative settings that better suited with large text and another colourscheme.

I didn’t really like the approach of having two terminal emulators, so I decided to do some research to see if I could solve it by only using my main terminal emulator URxvt. Spoiler: I could.

It turns out that you can add alternative settings for URxvt and then optionally enable them with an argument. I found out about this in an old thread over at the Arch Linux forums.

How it works

You can add a custom setting with the name URxvt-<word>, like URxvt-tv and when you run URxvt wit the flag -name URxvt-tv it will use these settings.


I added the following settings to my file ~/.Xresources:

! TV settings

URxvt-tv.font: xft:Monospace:pixelsize=40

! Tango colours 
URxvt-tv.background: #000000
URxvt-tv.foreground: #FFFFFF

! Black dark/light
URxvt-tv.color0:             #2e3436
URxvt-tv.color8:             #6e706b
! Red dark/light
URxvt-tv.color1:             #cc0000
URxvt-tv.color9:             #ef2929
! Green dark/light
URxvt-tv.color2:             #4e9a06
URxvt-tv.color10:            #8ae234
! Yellow dark/light
URxvt-tv.color3:             #edd400
URxvt-tv.color11:            #fce94f
! Blue dark/light
URxvt-tv.color4:             #3465a4
URxvt-tv.color12:            #729fcf
! Magenta dark/light
URxvt-tv.color5:             #92659a
URxvt-tv.color13:            #c19fbe
! Cyan dark/light
URxvt-tv.color6:             #07c7ca
URxvt-tv.color14:            #63e9e9
! White dark/light
URxvt-tv.color7:             #d3d7cf
URxvt-tv.color15:            #eeeeec

When I run the command urxvt -name URxvt-tv it will launch URxvt with my alternative settigns.


This is not related to the title of this post but I thought I would include it anyway. I wanted to be able to instantly spawn the “TV terminal” on my TV from any monitor and workspace and have it automatically disable the decoration. I solved this by adding this keybinding to i3:

bindsym Mod4+Return workspace 10; exec --no-startup-id "tvterm"

I also added these two rules to i3::

for_window [title="tvterm"] border none
workspace 10 output HDMI-0

The script tvterm includes this snippet:


urxvt -name URxvt-tv -hold -e sh -c 'printf "\33]2;%s\007" "tvterm"; zsh'

I don’t know why, but I didn’t get it to work when I added that command direcly to the configuration file for i3. And the printf part is to trigger the rules for i3.

How to install rTorrent with the colour-patch in Debian

I installed rTorrent from source code so I could patch it with the colour-patch on my Raspberry Pi the other day and I thought I would document it here as well.

As of writing this post the latest version of rTorrent is 0.9.8 and the latest version of libtorrent is 0.13.8.

Downloading the required files

Start by downloading the source code for rTorrent and libtorrent from their website:

$ wget

We then need to download the patch that adds some lovely colours to rTorrent. I used the patch from the package rtorrent-color from the Arch User Repository:

$ wget

Continue to unpack the archives:

$ tar -xvzf rtorrent-0.9.8.tar.gz
$ tar -xvzf libtorrent-0.13.8.tar.gz 
$ tar -xvzf rtorrent-color.tar.gz

Installing the needed dependencies

Install the required dependencies:

# apt-get build-essential build-dep rtorrent libtorrent

Installing libtorrent

Start by going to the folder libtorrent-0.13.8:

$ cd libtorrent-0.13.8

Configure and install the package:

$ ./
$ ./configure --disable-debug
# make install

The flag --disble-debug is optional.

Patching and installing rTorrent

Go to the folder ../rtorrent-0.9.8:

$ cd ../rtorrent-0.9.8

Apply the patch:

$ patch -up1 -i <path to patch>/rtorrent-0.9.8_color.patch

Configure and install the package:

$ ./

You now have two options; to enable or disable remote connections for rTorrent. If you don’t connect to rTorrent via a third party client like ruTorrent or Transdroid I highly suggest you disable the feature.

With support for remote connections:

$ ./configure --disable-debug

Without support for remote connections:

$ ./configure --disable-debug --without-xmlrpc-c

Then continue to install the software:

# make install

Configuring rTorrent

The configuration file for rTorrent is $HOME/.rtorrent.rc and this is the part of the config that adds the colours:

# 0 = black
# 1 = red
# 2 = green
# 3 = yellow
# 4 = blue
# 5 = purple
# 6 = cyan
# 7 = grey
# 8 = dark grey 9 = dark red
#10 = dark green

color_inactive_fg = 3
color_dead_fg = 1
color_active_fg = 6
color_finished_fg = 2

This is my configuration file for rTorrent:

# General settings

max_peers = 200
max_peers_seed = 100
max_uploads = 50
download_rate = 0
upload_rate = 0
session = /home/johan/.rtorrent/session
schedule = low_diskspace,5,60,close_low_diskspace=100M
port_range = 58152-58162
port_random = no
check_hash = no
encryption = allow_incoming,try_outgoing,enable_retry
dht = off
peer_exchange = no

# Colors

## 0 = black
## 1 = red
## 2 = green
## 3 = yellow
## 4 = blue
## 5 = purple
## 6 = cyan
## 7 = grey
## 8 = dark grey 9 = dark red
## 10 = dark green

color_inactive_fg = 3
color_dead_fg = 1
color_active_fg = 6
color_finished_fg = 2

# Notifications

method.set_key =,notify,"execute2=/home/johan/Scripts/,$"

# Folders

schedule = watch_directory_torrents, 5, 5, "load.start=/mnt/hdd0/.torrents/*.torrent,"


This script (as specified in the configuration file) gets executed every time rTorrent completes a torrent and sends me a message about it via XMPP using sendxmpp:


echo "New torrent!\n\n$1" | /usr/bin/sendxmpp --tls-ca-path="/etc/ssl/certs" -t <My XMPP-account>

If you run rTorrent locally and just want a desktop notification, you can just replace the content with this:


notify-send "New torrent!" "$1"

How to view posts in alphabetical order by tags and title in Jekyll

This issue was driving me nuts the other day, I could not find a solution to it and I’m not knowledeable enough to have figured it out myself. All credits goes to a user called Sheogorath on the IRC-channel #Jekyll at for helping me with this.

So. I wanted to be able to list all my posts in an alphabetical order by tags and then sort each of these posts by title, not by date like it would by default.


My desktop

  • I went from a multi monitor setup to just a single monitor setup
  • My Desktop - Mars 2019

My keyboards

  • My keyboard - KBParadise V60
  • My keyboard - Let’s Split
  • My keyboard - The Black Diamond

The code

And this is how it can be done:

{% assign tags_sorted = site.tags | sort %}
{% assign posts_sorted = site.posts | sort: 'title' %}
{% for tagitem in tags_sorted %}
<!-- for each tag, create an anchor by using the tag name as an id -->
<div id="{{ tagitem[0] }}">
  <h3> {{ tagitem[0] }} </h3>  <!-- for create a heading -->

  <ul> <!-- create the list of posts -->
    <!-- iterate through all the posts on the site sorted by alphabet-->
    {% for post in posts_sorted %}
      <!-- list only those which contain the current tag -->
      {% if post.tags contains tagitem[0] %}
            <a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
      {% endif %}
    {% endfor %}
{% endfor %}

How to send a message to running X Windows sessions in a multi-user Linux system

, 02/06/2020 | Source: Fitzcarraldo's Blog

The ‘wall‘ command can be used to broadcast a message from a TTY console to other logged-in TTY console users in a multi-user Linux system. The Linux command ‘notify-send‘ can be used to send a message (a.k.a. notification) within an X Windows session, and Desktop Environments such as KDE and GNOME use notify-send to display pop-up […]

How to check how long it took to install a package in Gentoo

With the help of the tool qlop from the collection of utilities called q applets you can check how long it took to install a package in Gentoo. qlop reads from your log $EMERGE_LOG_DIR/emerge.log and extracts relevant information.

# qlop -Ht qtwebengine

2020-02-19T16:58:02 >>> dev-qt/qtwebengine: 2 hours, 14 minutes, 17 seconds
2020-03-31T01:27:45 >>> dev-qt/qtwebengine: 2 hours, 12 minutes, 43 seconds
2020-05-28T10:24:16 >>> dev-qt/qtwebengine: 2 hours, 22 minutes, 6 seconds

The flag -t lists all installations and the flag -H prints the time in a human readable format. If you would like to see the average time it has taken to install a certain package you can do so with the flag -a:

# qlop -Ha qtwebengine

dev-qt/qtwebengine: 2 hours, 6 minutes, 24 seconds average for 19 merges
dev-qt/qtwebengine: 2 seconds average for 1 unmerge

Don’t forget to check out all the available features with the flag --help.


The tool is available in the package app-portage/portage-utils:

# emerge --ask app-portage/portage-utils

How to automatically run a resume script with pm-utils as a regular user

I’m using Gentoo with OpenRC and I use the tool pm-utils to suspend my computer. The only issue I have with their way of automatically running a command when you resume your computer is the fact that it’s executed as root.

The command

If you want to run a command as any user you easily do that by using sudo:

$ sudo -H -u <user> sh -c "<command>"

Here’s an explanation of the flags I’m using:

-H, --set-home Request that the security policy set the HOME environment variable to the home directory specified by the target user’s password database entry. Depending on the policy, this may be the default behavior.
-U user, --other-user=user Used in conjunction with the -l option to list the privileges for user instead of for the invoking user. The security policy may restrict listing other users’ privileges. The sudoers policy only allows root or a user with the ALL privilege on the current host to use this option.

The script

Here’s an example script, it’s one of my scripts called 00refresh:

case $1 in
        sudo -H -u johan sh -c "DISPLAY=:0.0 /home/johan/Scripts/"
    *)  exit $NA

The script is placed in the folder /etc/pm/sleep.d/ and made executable. The number 00 in the beginning of the filename defines the sleep hook ordering convention. When you set it to something between 00 and 49 it assumes the usual services and userspace infrastructure is still running, you can read more about that in the manual.

How to save disk space by changing the reserved blocks for Ext-filesystems

By default the Extended-filesystem, more known as Ext2/4, reserves 5% of the filesystem blocks on the filesystem for privileged processes. It’s done to avoid filesystem fragmentation and to allow system daemons to continue to function correctly after non-privileged processes are prevented from writing to the filesystem due to a full filesystem.

It’s a great feature for system critical filesystems, but if you have a storage disk you usually don’t need that feature at all. And if you have a very large system disk you could probably lower the value a bit, but that’s for you to decide.

An example with my storage disk

I have turned off the reserved blocks on my storage disk and as you can see below it does make a noticeable difference on a larger filesystem.


$ df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       3.6T  1.9T  1.6T  55% /mnt/hdd0


$ df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       3.6T  1.9T  1.8T  52% /mnt/hdd0


Start by checking the amount of reserved block count you have on the disk:

# tune2fs -l /dev/sdb1  | grep 'reserved block count'

Reserved block count:     48837696

If you don’t know what your device names is you can list them with the command fdisk -l as a privileged user. In my case the device name was sdb1.

To change the value we are going to use the tool tune2fs. In this example I changed the value to 0 (zero) with the flag -m0:

# tune2fs -m0  /dev/sdb1

tune2fs 1.45.5 (07-Jan-2020
Setting reserved blocks percentage to 0% (0 blocks)

You can then double check to see if it worked:

# tune2fs -l /dev/sdb1  | grep 'reserved block count'

Reserved block count:     0

How to prevent NeoMutt from making line breaks in Neovim when you compose a message

When I compose a message in my e-mail client NeoMutt my editor Neovim inserts automatic line breaks after about 73 characters. I don’t like it at all.

Thankfully you can easily fix this by adding a few parameters to the $EDITOR for your NeoMutt configuration file:

set editor="vim +':set textwidth=0' +':set wrapmargin=0' +':set wrap'"

This should work fine with Mutt and Vim as well.

Why I like Gentoo

I like Gentoo for several reasons! Two of the reasons is the fact that Gentoo makes my computer fun to use (again) and that their friendly and helpful community always brings a smile to my face.

I also like the atmosphere around Gentoo, it’s laid back and fairly.. meta. I feel like most Gentoo users seems to think of Gentoo as a tool rather than anything else, a personalized tool for your own personal needs.

There’s no elitism at all in the land of Gentoo and you don’t get any extra “Internet karma” for using some weird piece of software by some obscure project and you won’t get hated on for choosing to install the ‘wrong’ init-system or any ‘mainstream’ software, like a major desktop environment. As a long time user of other Linux based operating systems this was a truly fresh breath of air for me.

If you want to read about Gentoos philosophy in their own words I can highly recommend reading the philosophy of Gentoo by the creator Daniel Robbins.

Rolling release yet stable

With Gentoo you get what I call a semi rolling release model. When it comes to the default kernel they always use the longterm support (LTS) kernel and when it comes to other software they’re in no hurry to rush out anything brand new to the stable repository. If you for some reason want to install a newer version of any package you can at any time choose to do so with ease.

When it comes to most other Linux based operating systems and their packages that’s classified as “unstable”, you’re almost always left with just one option; to enable a whole repository with untested packages, which is almost never a good idea. With Gentoo on the other hand you can allow untested packages on a per-package level and a whole lot more.

Gentoo doesn’t rely on various repositories to separate stable and untested packages from each other, they instead use something called keywords. There’s two keywords for every architecture:

arch (Example: amd64, x86, ppc-macos) Both the package version and the ebuild are widely tested, known to work and not have any serious issues on the indicated platform.
~arch (Example: ~amd64, ~x86, ~ppc-macos) The package version and the ebuild are believed to work and do not have any known serious bugs, but more testing is required before the package version is considered suitable for arch.

You can add keywords for a specific package (or a whole category), a specific versions of a package and all versions of a package up to or after a specific version.

The package management system

Compiling your packages from source code with settings and optimizations specifically tuned for your hardware can sometimes give you a significant performance boost, but with todays hardware that is for most not relevant anymore. The real benefit with compiling your own software is that you gain a greater control over the software you use. It means that you can customize the compiler and the target-application options to better fit you and your system. If you don’t use a feature with a certain package why should you then have to install the package with that feature enabled in the first place?

With something called USE-flags you can easily enable and disable specific features for software both on a global and on a per-package level. As an example; there’s a USE-flag called perl which adds support for the programming language Perl for certain packages. My favourite terminal emulator URxvt comes with support for plugins via Perl and If I want it to support Perl I can just install the package x11-terms/rxvt-unicodeas is, since the USE-flag perl is enabled by default, but I don’t want to use Perl I can add the flag -perl to completely disable support for Perl and avoid installing any unnecessary packages.

Another thing that I like with Gentoo is the fact that it’s easy to set up your own local repository and add your own ebuilds. An ebuild is a text file with Bash syntax that instructs the package manager on how to compile the package.

A small note about installing packages in Gentoo

I let a friend read this draft before publishing it and it turns out he had totally misunderstood how you install packages in Gentoo using the default package manager emerge. He thought it was complicated, that you need to use make and know where to install files, but it’s actually just as easy as installing any package in any other Linux based operating system:

# emerge --ask <package>

That’s everything! The flag --ask/-a is optional, but I highly recommend using it so you get a chance to inspect what emerge wants to before it executes the command.

A better init

When the operating system I was using at the time switched over to systemd, I experienced a noticeable downgrade in terms of stability and usability. The two things that annoyed me the most wasn’t the stability issues, it was the binary logs and the fact that when I booted up and shut down the operating system I always had to wait 90 seconds for some issues with a service that was not working as intended.

I used systemd for several years and I really tried to like it for what it was, but I eventually gave up when I got fed up when something was always giving me a hard time. It did kill the fun in using computers for a while. It also didn’t help that they had (and still have) a weird approach to software design, an anti-UNIX philosophy and the fact that they sometimes makes controversial moves that no one really asked for.

I have been using Gentoo for years now and I have so far never had any real issues with their init-system OpenRC, for me it has been reliable, familiar and easy to use.

The documentation

The documentation is really good! The Gentoo wiki used to be regarded as the best documented wiki for a long time, but has in recent years been put down to a noble second place by the Arch Linux wiki.

The downsides

The (sometimes) downsides with Gentoo can be the very fact that you have to compile pretty much all software by yourself[1]. This can sometimes be an inconvenience for some on slow hardware, but if you do have a secondary computer with more horse power available you can set up Distcc on both computers and then distribute the compiling tasks between them across a network.

  1. Gentoo do provide some binary packages for some of the heavier packages like app-officelibreoffice-bin and dev-lang/rust-bin.

That’s all! I hope you liked reading my thoughts about Gentoo.

Generating test coverage for Sonar with maven, surefire and jacoco

Dirk Olmes
, 10/05/2020 | Source: Infoschnipsel und Wissenswertes

At work we’re using Sonar to keep our code quality under control. One integral part of code quality is test coverage and Sonar offers coverage metrics in the UI. However, the Sonar docs on code coverage are a bit sparse (at best) and don’t tell you the exact steps to run for getting coverage with a Maven build.

With a bit of googling I was eventually able to find the correct steps to get coverage. The key to success is the Jacoco Maven plugin. In a first Maven execution we let jacoco record coverage statistics while running the unit tests:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install

In the build log you see the jacoco-maven-plugin in action (we’ll get back to this in a while):

[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (default-cli) @ sonar-code-coverage ---
[INFO] argLine set to -javaagent:/.m2/repository/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar=destfile=/sonar-code-coverage/target/jacoco.exec

Then in a second Maven execution we’ll pick up those coverage statistics and convert them to XML so that Sonar can include them in its analysis:

mvn org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

Hooray! Coverage info in Sonar.

The trouble starts when you need to pass custom arguments through surefire down to the JVM that will run the tests. This is done through the <argLine> configuration parameter of maven-surefire-plugin:


Looking back at the output of jacoco-maven-plugin above you’ll notice that we’re setting exactly the same <argLine> parameter as jacoco-maven-plugin does. If you don’t take extra steps only one configuration can win - and that’s the configuration you put into your pom. You have to run mvn -X to actually see this, though:

[DEBUG] Forking command line: /bin/sh -c cd /sonar-code-coverage && /opt/openjdk-bin-8.252_p09/jre/bin/java -Xmx128m -jar /sonar-code-coverage/target/surefire/surefirebooter9099169912642065145.jar /sonar-code-coverage/target/surefire 2020-05-12T07-39-04_225-jvmRun1 surefire3709014631518520641tmp surefire_01706858247537265191tmp

Note how the -javaagent:... argLine is not included in the command line arguments of the JVM that’s forked to run the tests.

A way to fix this is through creative use of Maven build properties. Configure the jacoco-maven-plugin to set a different property than argLine:


Next, configure maven-surefire-plugin to include that property into its <argLine>:

        <argLine>-Xmx128m @{surefire.argLine.sonar}</argLine>

Note that you have to use late evaluation of the property because it’s not present when the Maven reactor starts but only after jacoco-maven-plugin has run.

Just one last hack is required to make the build work even if you don’t run jacoco coverage as part of your build. Specify an empty property surefire.argLine.sonar in your project’s properties so that it always exists and can be expanded.

For further reference I’ve put a demo project up on github.