Element is a Matrix protocol client which allows you to communicate end-to-end-encrypted (E2EE) with anyone else using the Matrix protocol. Matrix is “an open network for secure, decentralized communication” and Element is your gateway into this network.

This article shows you how to operate multiple distinct sessions of the Element Matrix client on Fedora Linux.

An open network for secure, decentralized communication

Matrix.org

A convenient way to operate an up-to-date Element client on your Fedora Linux is the Flatpak package. It is distributed via the Flatpak repository Flathub. Flatpak is an alternative package manager on Fedora Linux that considers itself the next-generation technology in building and distributing applications on Linux. Flathub is a public, distribution-agnostic repository.

An alternative gnome-native client is Fractal. Learn how to setup and use Fractal on the Fedora Magazine in Fractal: a GNOME Matrix chat client.

In some scenarios, most probably when using Matrix personally and at work, you want to operate multiple distinct sessions of Matrix on your Fedora Linux. Some clients like Element don’t feature a session selection or multiple logins in the same application window. Fortunately Element can start with different profiles. That’s what you and I are going to explore now. First you have to install Element, though. To do this you need the package manager Flatpak and the repository Flathub.

Install Flatpak, Flathub and Element

The Element Flatpak is distributed via Flathub. Begin by installing Flatpak and add the Flathub repository to it.

$ dnf install -y flatpak
$ flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

If you fancy more insight into Flatpak and Flathub visit the Fedora Magazine article on Getting Started with Flatpak.

Next install the Element Flatpak with flatpak install im.riot.Riot. After the installation is complete you should see a Desktop entry Element.

Element was once called Riot. Read up on its history in Element (Software) | Wikipedia

Setup multiple Matrix sessions

By default, Element will launch a nameless profile as your users primary session. The desktop entry of your window manager will most probably only open one session because of that default. The client itself, once started, does not provide a way to switch profiles nor to log into multiple accounts. Fortunately for you the terminal command features a ‐‐profile flag which you’ll use to your advantage.

The default desktop entry of your Element Flatpak installation is located under /var/lib/flatpak/exports/share/applications/im.riot.Riot.desktop. Its contents look like this:

[Desktop Entry]
Type=Application
Name=Element
Icon=im.riot.Riot
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/element --file-forwarding im.riot.Riot @@u %U @@
Categories=Network;InstantMessaging;Chat;VideoConference;
MimeType=x-scheme-handler/element;
StartupWMClass=element
Keywords=Matrix;matrix.org;chat;irc;communications;talk;riot;vector;
X-Flatpak=im.riot.Riot

The magic happens in the Exec= statement. Copy / modify this file and at the end of the Exec= line add the ‐‐profile flag. E.g. one with ‐‐profile personal and the other with ‐‐profile work. This instructs Element to use a different profile than the default one. If you installed the Element Flatpak with the ‐‐user flag, the desktop entry will be in ~/.local/share/flatpak/exports/share/applications/im.riot.Riot.desktop instead. In this case, substitute /var/lib/flatpak/exports/share/applications/im.riot.Riot.desktop to ~/.local/share/flatpak/exports/share/applications/im.riot.Riot.desktop in the following copy command:

$ cp /var/lib/flatpak/exports/share/applications/im.riot.Riot.desktop ~/.local/share/applications/im.riot.Riot-work.desktop
$ vim ~/.local/share/applications/im.riot.Riot-work.desktop
$ cat ~/.local/share/applications/im.riot.Riot-work.desktop
[Desktop Entry]
...
Name=Element (work)
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/element --file-forwarding im.riot.Riot @@u %U @@ --profile work
...

A little quirk: if you already started one session with a ‐‐profile flag the original without the flag won’t start. It works the other way around though.

If you want to change the name of an existing profile you simply rename the profile folder from your home directory under ~/.var/app/im.riot.Riot/config. The default profile is called Element while the new work profile is called Element-work.

Summary

Nice! You setup Flatpak and Flathub on your device and gained access to many awesome Flatpak packages out there. You then installed the Element Flatpak before you setup multiple desktop entries to conveniently open up any number of distinct matrix account sessions.

Did you know that you can access the freenode / IRC world through Matrix? Check it out on the Fedora Magazine in Access freenode using Matrix clients.

Alexander Wellbrock

Alex love for Free and Open Source Software ignited through his fascination of its design and principles. His private and professional lives are driven by the self-efficacy enabled through simple but beautiful, free and open systems. He is asking himself “How can we thrive through collaboration instead of competition?” and is certain the answer to this utilizes FOSS.

Posted by Contributor