Thorsten Zöller

Running Anki inside Xephyr

Anki is a great tool for memorizing things, like words in a foreign language you want to learn. I am using it for memorizing Vietnamese words in my endeavor to learn Vietnamese.

I am currently running Anki 2.1.16 on OpenBSD 7.1. Unfortunately, quite often Anki freezes after using it for some time, without any advance notice. When this happens, I can no longer do anything except moving the mouse pointer. I cannot switch windows and not even switch to the console in order to forcefully quit Anki. Apparently, it crashes the whole system, and the only way out is a forceful reboot.

I do not know what causes this behavior or if there is any fix for it. It seems that I am not the only one experiencing this, but I have not yet found a solution to this behavior.

I did find a workaround, however: Running Anki inside of Xephyr(1) (a nested X server that runs as an X application and is part of OpenBSD base) seems to prevent it from freezing. The workaround involves three steps:

  1. Launch Xephyr on display :1 (or any other display differing from your main display, which is usually :0).
  2. Launch cwm inside the Xephyr window just created (it is necessary to run a window manager since Anki employs multiple windows in general; of course, any other window manager can be used as well).
  3. Lauch Anki inside the Xephyr window.

For convenience, I have created a small shell script for executing these steps:

Xephyr -br -ac -noreset -screen 1920x1080 :1 &
cwm -c .cwmrc_xephyr -d :1 &
DISPLAY=:1 anki &

Of course, the value of the screen command line parameter of Xephyr needs to be adjusted to your screen size. Also, I run cwm in the Xephyr window with a specific configuration file.

It works well, but strangely, after a while cwm seems to stop running inside Xephyr. This is inconvenient because it makes it impossible to switch between different Anki windows. The solution is to simply restart cwm by manually executing the second line of the script again.

Obviously, this is not a real fix to the problem, but it works. Hopefully, Anki will get more stable in the future so that this workaround will no longer be needed.