I’m taking a break from Mastodon

For an indefinite future. *Dramatic drumroll* Well. Seriosly talking, I just feel like that I might not using it in a way that I want to be using it anymore.

I feel like that I would like to take a break from Mastodon[1] and see what happens with my phone usage in general. I access Mastodon 95% of the time via my phone and according to my phone I have opened Tusky (my Mastodon-client) in average about 30 to 50 times per day the last month or so. One day it was 100 times! That’s just crazy.

  1. This only applies for my main account, where I spend 99.99% of my time on Mastodon. I still use Mastodon for my project Linuxkompis and my company I/O Keyboards.

I can only imagine how much of an effect that distraction must have on my life in general. And since Mastodon is the only distraction I have on my phone these days, I’m hopeful that by removing my account it will result in something positive, like bringing back my passion for weblogs and the old web again.

To be honest, I have always considered myself to be a ‘healthy’ low-usage phone user, mostly spending my time modifying my phone with custom firmwares and icon packs, rather than using it for anything else. And sure, I once was that person, but something obviously happened along the road. I don’t know what, but I intend to find out what happened when I got lost and how I can find my way back again.

I now feel that I want to focus more on my weblog. I would like this to be my new social corner of the web, but for it to be truly social I probably need a commenting system. I’m not sure what to use yet, but I’m looking for options.

If you want to contact me and/or leave feedback you can do so via e-mail and IRC (I’m Hund at freenode).

Audio cracks with Intel HD (and reflecting with some USB devices).

Menelkir
, 18/09/2020 | Source: Daniel Menelkir

I had this problem with two different Intel HDs (also this problem reflects into my M-Audio USB). I'll let this registered here.

This solution is in case you have crackling sounds (something like a jitter from time to time) and an error in dmesg similar to IRQ timing workaround is activated for card #1. Suggest a bigger bdl_pos_adj.

In my case, disabling the onboard Intel HD in bios doesn't work and the jitter still occurs

Fix:

/etc/modprobe.d/sound.conf

options snd-hda-intel bdl_pos_adj=2,2

Your mileage may vary, so mess around with this number until it fixes for you, always using the power of 2.

I gave my website a new look

I gave my website a new look! I wasn’t happy with the code and some parts of the theme. I have also wanted to try a more ‘plain text’ look for some time now and decided to give it try. It turned out to be more challenging than I expected to design something simpler with less visual elements.

I started fresh with a new theme from scratch. This made it easier to improve the parts of the old code that I didn’t like from my previous theme. I was able work with a lot less code which was a lot of fun. I managed to remove 16 kilobytes of code and my website[1] is now down to 220 kilobytes of code.

  1. Pre-build and excluding images and posts.

If you like my theme you can find the source code here. If you have any feedback on the theme itself or my code (good or bad), feel free to contact me and let me know about it.

Tor proxy 101

I realize I haven’t published for a while again, this new blog entry aims to inaugurate the new Tor version of my website that you can easily find if browsing through Tor or head to the Privacy Policy section of this blog. In this blog post, I will shortly explain what the Tor network is, why it matters, and why every website should run a .onion version. Then on the second hand, I’ll describe step by step how anyone can create a Tor proxy of their favorite website using a cheap VPS.

Ranger - My favourite file manager

Ranger is a file manager written in Python that uses the well-known text-based interface ncurses. The layout for displaying files and folder is called Miller columns, a three column based layout that’s commonly used for file managers. Ranger is a Vi-like file manager, which means that the keybindings and workflow is highly inspired from the Vi text editor. It even features some (optional) support for the mouse, but what makes it great (if you ask me) is the epic support for a key-based workflow.

My setup with Ranger and the Solarized colourscheme.
My setup with Ranger and the Solarized colourscheme.

My adventures with Ranger

Even though I’ve been an avid user of everything text-based for a long time, I was sceptic over using a text-based file manager. Could it really be as fast or as convenient as a graphical file manager? Well. It turned out I was wrong, so wrong!

The first days with Ranger felt a little bit awkward, kind off like how it felt with Vim the first time, but at the same time you instantly knew you were onto something good. I was using the basic navigation with the keys j and k to navigate up and down, gg and G to jump to the top and bottom and '<LETTER> for my bookmarks. While it did work, it wasn’t very efficient and browsing larger folders took me forever. This could have all been avoided if I hadn’t just quickly skimmed through the documentation and instead thoroughly read (at least most of) the documentation first.

It wasn’t until I read the whole documentation that I found out about the “find” feature, a feature that lets you quickly search for files and folders. It works by hitting the letter f and then typing some of the characters from the file or folder you’re looking for. If you end up with a unique hit it will open the file or folder directly and you can also at any time navigate between the hits with the keys n and tab. This way of navigating made a large impact on the efficiency for me and it also convinced me that a text-based file manager can actually be more efficient.

With that said. I wasn’t 100% satisfied with the find-feature until I found out about a neat little tweak to the it! By rebinding f to the function scout -ftsea%space I was now able to visually filter out all non-hits, making it a lot easier to find what I’m looking for. I made a little animated GIF-image to demonstrate what I’m talking about:

If you want to do the same thing, add this line to your configuration file ~/.config/ranger/rc.conf:

map f console scout -ftsea%space

Features

Ranger comes with a lot of features and if that’s not enough, it’s also possible to add new functionality with scripts and plugins. As this is meant to be an introduction to Ranger I will only cover some basics here.

Thumbnails

The first thing you might ask yourself is: “What about thumbnails?”. Well. Showing thumbnails for images might be considered to be one of the most basic features a file manager should have by some. And they’re right.

Ranger can show a (single) preview/thumbnail of pretty every file there is—even archives (using atool) and torrent-files (using transmission-show)—the issue is that it can only preview the currently marked file. Which is perfectly fine for everything but images. A solution to this is the image viewer sxiv, which can show thumbnails for images.

I wrote about sxiv back in 2018: “sxiv - A simple Vi-like image viewer”. It’s a great lightweight and scriptable image viewer that I highly recommend everyone checking out!

The keybindings

What makes Ranger truly great is the keybindings. To give you an idea how it could work, I have included some of the common keybindings for me. Some of them are defaults and some of them are my own. I’m not really sure which ones are the defaults or not though, I’ve been using Ranger for a very long time now.

File management

H Show hidden files and folders.
r Open with <APPLICATION>.
D Delete the marked file or the selected files.
<Space> Selects the current file/folder.
v Marks all files and folders in the current directory.
a Edit the name of the file/folder by putting the cursor last.
I Edit the name of the file/folder by putting the cursor first.
cw Change the name of the file/folder.
o Sort current directory. oa to sort by time os to sort by name size and so on.
'<LETTER> Jump to bookmark.
m<LETTER> Bookmarks the current directory.
:bulkrename Lets you bulk rename the selected files and folders by using your $EDITOR.

Tabs

gn opens a new tab.
gc closes the current tab.
<Tab> switches tab to the right.
<Shift>+<Tab> switches tab to the left.

Some of my custom keybindings

This is some of the keybindings that I actually know that I have added myself.

F Executes detox %f on the current file or folder. Detox makes file names pretty by removing troublesome characters and spaces.
Md Creates a folder.
U Uploads the selected file(s) and/or folder(s) to my Nextcloud account using shareLinkCreator.
Pp Creates a PDF-document of the selected document using Pandoc.
Ph Creates a HTML-document of the selected document using Pandoc.
px Extracts the archive using atool.
pat Creates an archive using tar.
paz Creates an archive using zip.
w Sets the current image as a wallpaper using feh.

If you’re at any time lost and/or need any kind of help in Ranger, you can just press the key ? to bring up this dialog that will help you:

View [m]an page, [k]ey bindings, [c]ommands or [s]ettings? (press q to abort)

Plugins

To install a plugin you simply copy it to the folder $XDG_CONFIG_HOME/ranger/plugins/. I only have one plugin myself and that’s a plugin called plugin_file_filter.py, it’s a plugin that visually hide files and folders. Why? The main reason I installed it is so I can hide the folder ~/Desktop. I don’t have a desktop, so why would I want to see the folder?

You can find more plugins on their wiki.

There’s more

This is far from everything that Ranger can do, my hope is that what I covered here today is enough to help peak the interest for you with Ranger and to try it out yourself!

I highly recommend you checking out their cheatsheet (PNG / SVG), the official user guide and the rest of the wiki for all the information available about Ranger.

And if you’re interested in looking at my latest public configuration for Ranger it’s available online via my public Git-repository for Ranger and other dotfiles.

Migrating to libglvnd in Gentoo Linux on a laptop with NVIDIA Optimus

Fitzcarraldo
, 16/08/2020 | Source: Fitzcarraldo's Blog

In a 2015 post I described how I configured my Gentoo Linux installation to switch between the closed-source NVIDIA driver and the open-source Intel driver on a Clevo W230SS laptop that has NVIDIA Optimus hardware (NVIDIA GeForce GTX 860M GPU plus Intel HD 4600 IGP). I did not want to use Bumblebee, preferring to use […]

How to make eix in Gentoo look good with the Solarized colourscheme

Something that has always been bothering me with the tool eix is the default colours when you use the Solarized colourscheme for your terminal emulator.

Thankfully I found a solution to that today and eix looks a lot better for me now. Here’s a comparison with a before and after images:

I found the solution in this post over at the Gentoo forums. The solution is to simply set the variable SOLARIZED=true in your shell. You do this with the command export SOLARIZED=true. If you want to make it permanent you just add it to your configuration file for your shell.

How to sync and manage your CalDAV-calendars and your CardDAV-addressbooks via the terminal

If you want to sync and manage both your CalDAV-calendars and your CardDAV-addressbooks via the command-line you’re in luck! There’s three pieces of software called vdirsyncer, Khal and Khard that does just that for you. It happen to be how I’ve been doing it for several years now and I think it’s time to write about it.

Setting it all up is pretty easy and straightforward, as long as you know what to do. You can either read the documentation or just be happily lazy and copy my pretty generic setup that I use with both my Nextcloud account and a public read-only calendar from Google, so I can keep myself à jour with our holidays here.

How to get started with vdirsyncer

It’s wise to start with the backend. The file file you need to edit is ~/.config/vdirsyncer and this is what my configuration file looks like (It should be safe to copy this and the other configuration files and just make minor obvious adjustments to them):

[general]

# A folder where vdirsyncer can store some metadata about each pair.
status_path = "~/.config/vdirsyncer/status/"

# CardDAV
# =======

# Operation Tulip
# ---------------

[pair nextcloud_contacts]
# A `[pair <name>]` block defines two storages `a` and `b` that should be
# synchronized. The definition of these storages follows in `[storage <name>]`
# blocks. This is similar to accounts in OfflineIMAP.
a = "nextcloud_contacts_local"
b = "nextcloud_contacts_remote"

# Synchronize all collections that can be found.
# You need to run `vdirsyncer discover` if new calendars/addressbooks are added
# on the server.
collections = ["from a", "from b"]

# Synchronize the "display name" property into a local file (~/.contacts/displayname).
metadata = ["displayname"]

# To resolve a conflict the following values are possible:
#   `null` - abort when collisions occur (default)
#   `"a wins"` - assume a's items to be more up-to-date
#   `"b wins"` - assume b's items to be more up-to-date
#conflict_resolution = null

[storage nextcloud_contacts_local]
# A storage references actual data on a remote server or on the local disk.
# Similar to repositories in OfflineIMAP.
type = "filesystem"
path = "~/.config/vdirsyncer/contacts/"
fileext = ".vcf"

[storage nextcloud_contacts_remote]
type = "carddav"
url = "https://cloud.operationtulip.com/remote.php/dav/addressbooks/users/<USERNAME>/contacts/"
username = "<USERNAME>"
password = "<PASSWORD>"

# CalDAV
# ======

# Operation Tulip
# ---------------

[pair nextcloud_calendar]
a = "nextcloud_calendar_local"
b = "nextcloud_calendar_remote"
collections = ["personligt", "fdelsedagar", "temadagar"]

# Calendars also have a color property
metadata = ["displayname", "color"]

[storage nextcloud_calendar_local]
type = "filesystem"
path = "~/.config/vdirsyncer/calendars/"
fileext = ".ics"

[storage nextcloud_calendar_remote]
type = "caldav"
url = "https://cloud.operationtulip.com/remote.php/dav/"
username = "<USERNAME>"
password = "<PASSWORD>"

# Helgdagar
# ---------

[pair helgdagar]
a = "helgdagar_local"
b = "helgdagar_remote"
collections = null

[storage helgdagar_local]
type = "filesystem"
path = "~/.config/vdirsyncer/calendars/helgdagar/"
fileext = ".ics"

[storage helgdagar_remote]
type = "http"
url = "https://calendar.google.com/calendar/ical/sv.swedish%23holiday%40group.v.calendar.google.com/public/basic.ics"
read_only = "true"

My calendar “fdelsedagar” is actually named “Födelsedagar”, vdirsyncer just removed the letter “ö” for some reason.

When you’re done setting up vdirsyncer you need to ‘discover’ both the calendars and the addressbooks with the command:

$ vdirsyncer discover

You can then synchronize everything with the command:

$ vdirsyncer sync

And you’re done! I highly recommend you scheduling the command using Cron. I have this in my configuration file for it to sync every three hours:

*/180 * * * * vdirsyncer sync

How to get started with Khal

The config is located at ~/.config/khal/config and my configuration file looks like this:

[default]

default_calendar = Personligt
highlight_event_days = true

[view]

dynamic_days= false

[locale]

unicode_symbols = false
local_timezone = Europe/Stockholm
default_timezone = Europe/Stockholm
timeformat = %H:%M
dateformat = %d.%m
longdateformat = %d.%m.%Y

[calendars]

[[Personligt]]
  path = ~/.config/vdirsyncer/calendars/personligt/
  color = light cyan

[[Födelsedagar]]
  path = ~/.config/vdirsyncer/calendars/fdelsedagar/
  color = dark blue

[[Helgdagar]]
  path = ~/.config/vdirsyncer/calendars/helgdagar
  color = yellow

Once it’s setup you can start using Khal. It comes with both a text-based user interface as well as a command-line interface. The syntax for the commands can be a bit tricky to figure out if you’re new and clueless, but the interactive mode is really simple.

When I was new I had issues remembering the syntax for the time and date. For some reason you format the syntax like this: <DD>.<MM>. <HH>:<MM> <HH>:<MM>, for an example: 12.08. 18:00 22:00. Which doesn’t make much sense to me. Something more sensible would be something like 12.08 18:00-22:00.

Anyway. Here’s a few examples of what you can do via the command-line:

$ khal printcalendars

List all events between today and 30 days forward:

$ khal list today 30d
Tuesday, 25.08.2020
 Linux födelsedag (R)

Adding a new entry

On a specific date (in this example it’s October 12 between the clock 18:00 and 22:00):

$ khal new 12.08. 18:00 22:00 "Laundry"

You can also specify dynamic dates, alarms, a specific calendar and a description:

$ khal new tomorrow 18:00 22:00 -alarm 10m -a <CALENDAR> "<TITLE> :: <DESCRIPTION>"

If you want it to be a recurring event:

$ khal new 12.08. "<EVENT>" -r <yearly/monthly/weekly/daily>

There’s also the flag -u, –until if you want it to be for a limited time only.

Searching for an event

$ khal search <KEYWORD>

Editing an event

When you want to edit an event you simply use a search keyword (like “Linus”):

$ khal edit --show-past "Linus"
28.12-28.12 Linus Torvalds födelsedag (R)
Edit?  [n]o  [q]uit  [s]ummary  [d]escription  da[t]etime range  re[p]eat
[l]ocation  [c]ategories  [a]larm  [D]elete: 

Importing a calendar from a file

It’s also possible to import calendars from ICS-files:

$ khal import -a <CALENDAR NAME> <FILE> 

The interactive mode

And if you want to use the interactive mode:

$ khal interactive

You can add a new event using the interactive mode without first running Khal, even though this method can be a bit annoying if you do it wrong:

$ khal new -i
summary: Test
datetime range: 12.08 13.08 13:00 15:00
critical: Could not parse "12.08 13.08 13:00 15:00".
critical: Please check your configuration or run `khal printformats` to see if this does match your configured [long](date|time|datetime)format.
critical: If you suspect a bug, please file an issue at https://github.com/pimutils/khal/issues/ 

To be honest I have no idea how the “datetime” syntax work here. I only use the shell commands myself, but I highly recommend using the proper interactive interface with khal interactive and then pressing the key N.

I also highly recommend you reading the documentation for Khal regarding all the available commands and how they all work.

How to get started with Khard

For some reason the name scheme doesn’t follow its sibling. For Khard the configuration file is ~/.config/khard/khard.config. Here’s my configuration file:

[general]

debug = no
default_action = list
editor = nvim
merge_editor = colordiff

[addressbooks]

[[Personal]]
path = ~/.config/vdirsyncer/contacts/contacts

[contact table]

# display names by first or last name: first_name / last_name
display = first_name

# group by address book: yes / no
group_by_addressbook = no

# reverse table ordering: yes / no
reverse = no

# append nicknames to name column: yes / no
show_nicknames = no

# show uid table column: yes / no
show_uids = yes

# sort by first or last name: first_name / last_name
sort = first_name

[vcard]

# extend contacts with your own private objects
# these objects are stored with a leading "X-" before the object name in the vcard files
# every object label may only contain letters, digits and the - character
# example:
#   private_objects = Jabber, Skype, Twitter
private_objects = Jabber

# preferred vcard version: 3.0 / 4.0
preferred_version = 3.0

# Look into source vcf files to speed up search queries: yes / no
search_in_source_files = no

# skip unparsable vcard files: yes / no
skip_unparsable = no

Running just khard prints all the contacts like this:

$ khard
<INDEX NUMBER>   <NAME>       cell: <PHONE NUMBER>        home: <E-MAIL ADRESS>    <ID>

You can show an contact with the argument show:

$ khard show alex
Name: Alexander
Address book: Personal
Phone
    cell: <PHONE NUMBER>
E-Mail
    home: <E-MAIL ADRESSS>
Address
    home: 
        <ADRESS>
Miscellaneous
    UID: <UUID>

If you want to edit a contact using your editor:

$ khard edit alex

The file is to large to show here, but it contains a lot of sane syntax and comments to help you understand how it works. Here’s the part with “important dates”:

# important dates
# Formats:
#   vcard 3.0 and 4.0: yyyy-mm-dd or yyyy-mm-ddTHH:MM:SS
#   vcard 4.0 only: --mm-dd or text= string value
# anniversary
Anniversary : 
# birthday
Birthday : 1970-01-01

I once again recommend you reading the documentation for Khard regarding all the available commands and how they all work.

I didn’t go thought every possible bit, but it should be enough to get you started and going! I hope you enjoy this software as much as I do.

That UPS you bought for your home server may not be as useful as you think

Fitzcarraldo
, 09/08/2020 | Source: Fitzcarraldo's Blog

Some years ago I decided to install a server at home for use as a NAS (network-attached storage) in my home network, and for an Internet-facing server. I live in a place where blackouts are very infrequent (perhaps a couple per year), but occasionally the mains drops out for only a second or two. I […]

How to edit your music data tags using the command-line

The command-line tool Audiotag is an easy to use Perl-script for editing the data tags in your music files. It supports the formats MP3, OGG Vorbis, MP4, M4A and FLAC.

Example usage

To print information about a track you use the flag -l, --list-info:

$ audiotag -l 01_Claustrophobic_Amnesia.ogg

*** `01_Claustrophobic_Amnesia.ogg'
=== ALBUM: TENONDERGANG
=== ALBUMARTIST: Ter Ziele
=== ARTIST: Ter Ziele
=== COMMENT: Visit http://terziele.bandcamp.com
=== DATE: 2018
=== TITLE: Claustrophobic Amnesia
=== TRACKNUM: 1
=== TRACKNUMBER: 1

I noticed that the track is missing a genre, let’s set the genre for all the tracks of that album:

$ audiotag -g "Depressive suicidal black metal" *.ogg

It’s simple as that. To list all available features just use the flag -h, --help. I also highly recommend using the flag -p, --pretend to dry run the command if you’re not 100% sure about what you’re about to do.

Installation

The easiest option is probably to clone the Git-repository on GitHub and copy the script to your $PATH. Just make sure that you have installed Perl (version 5.6 or newer) and:

  • For MP3-support: id3tag or id3lib.
  • For OGG Vorbis-support: vorbiscomment from vorbis-tools.
  • For FLAC-support: metaflac from flac.

If you’re using Gentoo, these are packages you might be looking for:

  • MP3: media-libs/id3lib
  • OGG Vorbis: media-sound/vorbis-tools
  • FLAC: media-libs/flac
  • MP4/M4A: media-video/atomicparsley

If you don’t have support for a format it might annoyingly remind you about it every time you use the tool:

$ audiotag -h                                                                                           -- INSERT --
WARNING: `AtomicParsley' not found in path, required for mp4 support!
WARNING: `AtomicParsley' not found in path, required for m4a support!
[...]

As you can see I don’t have support for MP4 or M4A and I don’t care. I fixed this issue by commenting out two parts of the script between the lines 473-491:

# MCM - handle mp4 and m4a using AtomicParsley
elsif ($file =~ /\.mp4$/i or $file =~ /\.m4a$/i) {
	push @cmd, "AtomicParsley";
	push @cmd, $file;
	foreach (sort { $a cmp $b } keys %$info) {
		# don't need extra track num field
		/TRACKNUMBER/ && next;
		$plus_tags{$_} ||= "===";
		push @result, "$plus_tags{$_} $_: $info->{$_}";
	}
	if ($genre   ) { push @cmd, ("--genre", uc $genre);		}
	if ($artist  ) { push @cmd, ("--artist", $artist);		}
	if ($album   ) { push @cmd, ("--album", $album);		}
	if ($title   ) { push @cmd, ("--title", $title);		}
	if ($track   ) { push @cmd, ("--track", $track);		}
	if ($year    ) { push @cmd, ("--year", $year);			}
	if ($comments) { push @cmd, ("--comment", $comments);	}
	push @cmd, ("--overWrite", "--gapless", "true");
}

And the lines 663-664:

check_for_prog(\@filetypes, \@missing, "mp4", "AtomicParsley"     );
check_for_prog(\@filetypes, \@missing, "m4a", "AtomicParsley"     );

It then stopped complaining about it.