Getting Anki to run on Ubuntu 22.04

Whatever happened to Anki, which I had installed many major versions of Ubuntu ago, and which I only rarely use – it only started up with an empty screen today.

So I went to the Download Anki page, und downloaded the latest version (2.1.66), both for Qt5 and Qt6 to find a way to make it run again. Advantage: you can then start Anki with a simple ‘./anki‘ from the terminal without installing it.

I followed all the “you might be missing this” instructions for missing libraries, but still no luck with displaying anything but an empty start window (either grey or black, depending on the Qt version).

After going through the AnkiWeb forums, I found two hints that finally produced a functioning Anki window in Qt5:

$ QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" DISABLE_QT5_COMPAT=1 ./anki

After repeatedly verifying the successful application launch, I installed this Qt5 version using ‘./install.sh‘, and used the Menu Editor to set the parameters.

Which of course would not work the way I intended.

So the parameters had to go to a shell script which I created using

$ echo QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" DISABLE_QT5_COMPAT=1 anki > start-anki.sh

and used Menu Editor again to replace the original Command with

/home/Me/Tasks/start-anki.sh

Everything’s good now 🙂

Fixed: Evolution no longer asks “Do you want to recover unfinished messages?”

This bug was really annoying: You type an email in Evolution mailer and send it successfully, and the next time you start up Evolution again, you get that dialog

Do you want to recover unfinished messages?

and you are not sure whether you sent everything you wanted to send, and dare not press the Discard button, and end up with all the emails written since the last time you started the mailer.

Well, it happened again today, and I was more successful in tracking the bug down, and found 2 bug reports on Launchpad

1978260 Evolution not closing emails after sending

1983794 Evolution not deleting autosave files

and a Gitlab Evolution issue 1972.

Fortunately, the bug has been fixed in the meantime, and under Ubuntu 22.04.1 the issue can be fixed by installing the latest version of libcanberra:

$ sudo apt install libcanberra-gtk3-module

which updates the previously installed version

Get:1 http://at.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcanberra-gtk3-module amd64 0.30-10ubuntu1.22.04.1 [11,2 kB]
Fetched 11,2 kB in 0s (59,5 kB/s)
(Reading database … 515766 files and directories currently installed.)
Preparing to unpack …/libcanberra-gtk3-module_0.30-10ubuntu1.22.04.1_amd64.deb
…
Unpacking libcanberra-gtk3-module:amd64 (0.30-10ubuntu1.22.04.1) over (0.30-10ubuntu1) …
Setting up libcanberra-gtk3-module:amd64 (0.30-10ubuntu1.22.04.1) …

Editing the Gnome Applications menu

I have a couple of shell scripts that I run regularly, and currently they reside in a ~/Tasks directory. This means there is always an open window (Terminal or Files) so that I can invoke them easily (after finding this window).

I had this idea that somehow it should be possible to add a Tasks folders to the Applications menu, and call the script from menu items inside Applications, allowing for faster access.

So now I found this answer on AskUbuntu refering to a utility called menulibre, so I quickly installed it using

sudo apt install menulibre

and started it and indeed. it allowed me to add a Tasks folder (called “Directory” in menulibre) and various menu items (called “Launchers”, what would be “shortcuts” in windows) inside it.

Since these are file-based operations, you need to save every single item after editing it – apparently there is no “Save All” mechanism.

Under the hood, the application creates a menulibre-[name].directory file in ~/.local/share/desktop-directories for each directory, and menulibre-[name].desktop files for each item in ~/.gnome/apps and ~./local/share/applications.

The homepage of menulibre is here, and its repository can be found on GitHub.

Storing PostgreSQL databases on mounted volumes

I am not sure whether you can confirm a data directory for PostgreSQL during Ubuntu installation, but anyway, I ended up with the data directory located in the default location.

For some database experiments that I expect to be quite harddisk-consuming, I want to PostgreSQL to store this database on a different volume.

Following the comments on this question on SO and this answer on DBA, I first created a directory for PostgreSQL:

Continue reading

Fixing “simple-scan crashed with SIGSEGV”

I have an HP Envy 5030, and printing from Ubuntu (22.04, but also earlier versions) works fine, both via Windows Shared Printer and directly via USB.

Scanning, however, has always been a problem, as Ubuntu’s Document Scanner always crashed with the message

simple-scan crashed with SIGSEGV in _IO_new_fclose()

Scanning from the HP Device Manager also starts Document Scanner, so that’s option, and running hp-uiscan can’t find the scanner (“No device connected”).

Search through online forums, I found mention of XSane, and searching for XSane I found the Ubuntu page on XSane, stating

XSane can also be used from within The GIMP; just click

File > Acquire > XSane

to scan directly into an image.

Let’s give it a try.

According to the Man page of the Sane project, xscanimage will be used as a plug-in for Gimp.

$ xsane
Command 'xsane' not found, but can be installed with:
sudo apt install xsane
$ xscanimage
Command 'xscanimage' not found, but can be installed with:
sudo apt install sane

Installing…

$ sudo apt install xsane
$ sudo apt install sane

and linking the plug-in…

$ ln -s /usr/bin/xscanimage ~/.gimp-2.8/plug-ins/

I find various scanning options in the Gimp’s Plug-In Browser:

From Gimp’s menu, you can now find those connections under File > Create > xscanimage >

I finally managed to scan 1 image, but unfortunately, subsequent scans failed with the dialog message

Failed to open device `….’: Error during device I/O.

Printing still worked, though. Still, the issue bugged me.

I found various mentions of airscan-discover, but couldn’t figure out what it would do, so I ran the tool

$ airscan-discover
[devices]
  HP ENVY 5000 series [FD1005] (USB) = http://127.0.0.1:60000/eSCL/, eSCL

and added the line in the [devices] section of airscan.conf, as described here.

$ sudo nano /etc/sane.d/airscan.conf

Then I started

$ simple-scan "airscan:e0:ENVY 5000"

and it scanned!

And then I started Gimp and selected File > Create > xscanimage > airdrop:... and it scanned!

Ubuntu Jammy casualties: dotnet

Before I upgraded to Ubuntu 22.04 (Jammy), I had dotnet 5 and 6 installed, rather out of interest, than doing any serious programming.

As far as I can remember, I originally had installed the Snap version of dotnet, but had troubles installing any dotnet packages or templates, so I had switched to the “native” version of dotnet, probably using the dotnet-install.sh variant – I’m not sure.

Upgrading to 22.04 seems to have uninstalled dotnet 5, as it is out of support, and weird things happened to the dotnet 6 installation:

Running

dotnet new -i Avalonia.Templates

did not install the expected templates, but rather immediately returned the error message

The application ‘new’ does not exist

Further, the command dotnet --info listed two 6.0 runtimes, but did not know of any previously installed SDKs.

After uninstalling and re-installing and uninstalling the dotnet6 package, the command dotnet was still there, but did not do anything useful.

$ dotnet --list-sdks
A fatal error occurred. The folder [/usr/lib/dotnet/dotnet6-6.0.108/host/fxr] does not exist

This error message got me to dotnet/core Issue 5746 (dealing with .Net Core 3 on CentOS though), where a comment states

This can happen if dotnet-host and dotnet-hostfxr-3.1 are conflicting,

So I queried apt for the list of installed dotnet packages

$ apt list | grep dotnet

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

dotnet-apphost-pack-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-apphost-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-host/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64 [upgradable from: 6.0.108-0ubuntu1~22.04.1]
dotnet-hostfxr-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-hostfxr-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-runtime-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-runtime-deps-5.0/now 5.0.17-1 amd64 [installed,local]
dotnet-sdk-6.0-source-built-artifacts/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-sdk-6.0/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
dotnet-targeting-pack-5.0/now 5.0.0-1 amd64 [installed,local]
dotnet-targeting-pack-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet-templates-6.0/jammy-updates,jammy-security,now 6.0.109-0ubuntu1~22.04.1 amd64 [installed,auto-removable]
dotnet6/jammy-updates,jammy-security 6.0.109-0ubuntu1~22.04.1 amd64
libgtk-dotnet3.0-cil-dev/jammy 2.99.3-4build1 amd64
libgtk-dotnet3.0-cil/jammy 2.99.3-4build1 amd64

So I manually uninstalled all remaining dotnet packages

$ sudo apt-get remove dotnet-hostfxr-5.0
$ sudo apt autoremove

until the dotnet command was no longer recognized. From this clean state, I ran

$ sudo apt install dotnet6

and got a brand-new dotnet 6 environment and even a new application.

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.109
 Commit:    58a93139d8

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/dotnet6-6.0.109/sdk/6.0.109/

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: x64
  Commit:       163a63591c

.NET SDKs installed:
  6.0.109 [/usr/lib/dotnet/dotnet6-6.0.109/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/lib/dotnet/dotnet6-6.0.109/shared/Microsoft.NETCore.App]

File Organizers: Calibre

A long time ago, I had a look at Calibre to organize my e-books, but chose not to use it mainly because of one issue: Calibre uses its own directory structure to organize its e-books (library/author/title (id)), and also renames the files accordingly (truncated title - author.extension).

How should I ever find a book again, I thought, if the tool ignores my structure of sorting files? After all, I already created some kind of order on my file system, so that I should know where my books are.

Well, in the course of cleaning up a soon-to-be shut-down machine, I noticed that my e-book collection instead was really a huge mess, spread over several machines, discs, and directories, full of duplicates and copies – recognizable by file name or file size.

So, let’s throw it all on Calibre.

The nice thing about Calibre is that it stores its metadata not in the e-books, but in a local SQLite database and a metadata.opf OPF file for every book.

Also, using tags to organize books is more flexible and powerful as compared to the tree-like directory hierarchy of traditional file systems.

Still, I wanted to keep the original filename of any catalogued e-book, so I added the GetFileName plugin which automatically adds the original filename in a separate user-defined column.

To keep track of all the books I always wanted to read, and those I have already read, I installed the Reading List plugin.

Since Calibre warns you if you want to import a book already imported, and I always ignore those warnings, a lot of duplicates are going to end up in my e-book library. That’s where the Find Duplicates plugin is going to be helpful in the future.

Until then, a generic [todo] tag adorns all my Calibre books until the metadata is cleaned up.

Though still early in my book-cataloguing adventure, I already stumble across problems I still need to figure out.

  • How do you handle different spellings of an author’s name (plain name, with middle initial, with middle name) or pseudonyms?
  • How do you import HTML books spread over several pages?
  • How do you handle e-books split into chapter-wise PDFs?

Not all updates can be installed

If you run Ubuntu, you’ll notice that every now and then the Software Updater will provide you with a notification

Updated software is available for this computer. Do you want to install it now?

Except, when it does not, and instead displays a dialog

Software Updater: Not all updates can be installed

with a set of rather unintuitive buttons.

What is most disturbing is the list of possible causes, when it’s just a piece of software that checked all kinds of error conditions and should know what went wrong, and should be able to detail the error condition that prevents it from resuming its task, rather than the lazy “An error occurred”.

So I started to track the message down, and found:

  • Software Updater is a Python/GTK application residing in /usr/bin/update-manager
  • The application imports code from the UpdateManager package under /usr/lib/python3/dist-packages/UpdateManager
  • There, the MyCache class in Core/MyCache.py checks for various error conditions, and presents above dialog if something went wrong

It should be easy to adapt the code to display those error conditions. After a bit of trial and error, my version of the MyCache class displayed what kept the Software Updater from updating:

$ ./CheckUpdateManager.py
initializing
checking
would delete nodejs-doc
that's all

After removing the listed package

$ sudo apt-get remove nodejs-doc

Software Updater displayed its usual window of updatable software components.

The script CheckUpdateManager.py is available in my Python repository.

Disabling Loopback for Logitech G432 on Ubuntu

My old Logitech headset died a number of deaths (headband broken, cushion torn, finally cable broken), so I got myself a G432.

Unfortunately, using it in Teams under Ubuntu, I experienced an irritating loopback. Quickly took to the internets, but AskUbuntu was only of limited help.

For example, one answer suggested to use alsamixer, but that only completely muted the headset, not only the microphone loopback.

Another answer pointed me to a tool called HeadsetControl which allows exactly the control I wanted, and its Readme file even lists the model I have. Hurray.

I followed the instructions to install:

sudo apt-get install build-essential git cmake libhidapi-dev
git clone https://github.com/Sapd/HeadsetControl && cd HeadsetControl
mkdir build && cd build
cmake ..
make
sudo make install

After installation, I ran

$ headsetcontrol -?
Found Logitech G432/G433!
Supported capabilities:

* sidetone

And tried to set “sidetone” to zero:

headsetcontrol -s 0
Found Logitech G432/G433!
Failed to open requested device.
HID Error: (null)

Apparently, headsetcontrol requires sudo:

sudo headsetcontrol -s 0
Found Logitech G432/G433!
Success!

No more loopback!

Wordle cheat script

An article on The Register linked to a GitHub shell script version of Wordle, and what caught my eye was that apparently a Linux installation contains a dictionary of English words in the file /usr/share/dict/words.

If you are stuck in your daily Wordle, you can use this file to figure out solutions:

CommandPurpose
grep -E '^([a-zA-Z]){5}$' /usr/share/dict/wordscollect all 5-letter words
tr '[a-z]' '[A-Z]'convert words to upper case
grep 'RU...'filter words for matching (green) letters
grep '[E]'filter words for letters in the wrong spot (yellow)
grep -v '[ASD]'exclude known wrong letters (dark grey)

Combine the commands (the last 3 are optional) with the respective letters filled in, separated by the pipe “|”:

$ grep -E '^([a-zA-Z]){5}$' /usr/share/dict/words | tr '[a-z]' '[A-Z]' | grep 'RU.E.' | grep -v '[TASDLMN]'
RUPEE