For my research I use LabStreamingLayer (LSL) to manage my data collection. It’s easy of use and portability mean I can write my experiments or tools in whatever language I like.

The apps, while mostly basic, are reliable. I use the LabRecorder and Keyboard app constantly for my work. They’re small apps that serve a single purpose and both serve that purpose well. There’s only one drawback for me: Windows. The LSL team provide binaries for Windows that work well enough, but I use Linux for my work. For the start of my PhD I ran all my experiments on Windows and processed the Data on Linux.

I spend some of my free time developing Linux desktop apps (although sadly nothing public… yet). As I’m used to using the GNOME development tool-chain, I’ve used Flatpak alot in the past. I began to wonder if LSL would function well in a Flatpak container, so I wrote a simple program to see if LSL would work. This app would look for LSL outlet and let the user select one to visualise; It would then plot this graph into a GTK window using Matplotlib. I wrote it in Python as the liblsl-python package was available through pip and is natively cross platform (as it ships precompiled liblsl libraries). To my surprise, this worked flawlessly.

Figure 1: My demo program running on synthetic data generated by Openbci’s GUI application.

Figure 1: My demo program running on synthetic data generated by Openbci’s GUI application.

A few months passed and I was working on another python application that I wanted to use for experiments. However, this time I wanted to use my knowledge of GTK development and run the whole experiment using Linux. This meant I would need to get the LabRecorder working on Linux. No matter, it’s all open-source and uses Qt for the interface. However, my knowledge of compiling C/C++ programs is…. nearly non-existent; And the precompiled binaries of liblsl for Fedora (which were accepted in the repos in 2016) were abandoned and had to be removed from the repo before Fedora 31.

However, I decided to give compiling LabRecorder a go. It didn’t work. Lots of errors. No clue.

So I decided to try again but writing a Flatpak manifest instead. From my experience, flatpak-builder is pretty good at deciding how best to build a program so long as you tell it the correct build system. So, an hour of figuring out why Qt wouldn’t create a window and why the binary wasn’t appearing anywhere and voilà, I had a LabRecorder window running on Linux in a Flatpak!

Figure 2: LabRecorder running in a flatpak on Fedora 32.

Figure 2: LabRecorder running in a flatpak on Fedora 32.

Below is the flatpak manifest:

    {
      "app-id": "org.lsl.labrecorder",
      "runtime": "org.kde.Platform",
      "runtime-version": "5.14",
      "sdk": "org.kde.Sdk",
      "command": "LabRecorder",
      "finish-args": [
	"--share=network",
	"--share=ipc",
	"--socket=x11",
	"--env=QT_QPA_PLATFORM=xcb",
	"--env=DISPLAY=:0.0",
	"--socket=pulseaudio"
      ],
      "cleanup": [
	"/include",
	"/lib/pkgconfig",
	"/man",
	"/share/doc",
	"/share/gtk-doc",
	"/share/man",
	"/share/pkgconfig",
	"*.la",
	"*.a"
      ],
      "modules": [
	{
	  "name": "LSL",
	  "buildsystem": "cmake-ninja",
	  "sources": [
	    {
	      "type": "git",
	      "url": "https://github.com/sccn/liblsl.git",
	      "tag": "v1.14.0b3"
	    }
	  ]
	},
	{
	  "name": "LabRecorder",
	  "builddir": true,
	  "buildsystem": "cmake-ninja",
	  "sources": [
	    {
	      "type": "git",
	      "url": "https://github.com/labstreaminglayer/App-LabRecorder.git"
	    }
	  ],
	  "post-install": [
	    "ls",
	    "mv LabRecorder /app/bin/LabRecorder",
	    "mv LabRecorderCLI /app/bin/LabRecorderCLI"
	  ]
	}
      ]
    }

The manifest pulls in and builds both liblsl and LabRecorder on the org.kde.Platform (for the Qt and C++ libraries).

Where to go now? I’ve considered putting in a pull request to have this added to Flathub, but there’s no icon or .desktop file (and it would be inappropriate for me to create one without permission). I could also submit a pull request to have this in the LabRecorder repository, although I’m not sure they’ll be too thrilled at having an extra file to maintain. Admittedly, it’s not a complex file with much that needs changing, but still. Either way, this manifest exists and works. It might need updating in the future as new versions of liblsl and LabRecorder are released, but most likely all that will need changing is the tag for liblsl as LabRecorder starts to require newer versions.