Multiple Matrix sessions with Element on Fedora Linux

matrix

New Vector Ltd., Public domain, via Wikimedia Commons. Photo by Annie Sowards on Unsplash

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.

Using Software

14 Comments

  1. GroovieMan

    Never, never mess up your proper rpm driven distribution with dirty made packages like pacman! If you want file/version jam on you working environement, try Windows and get sick!

    I no package is available better use the webclient as a functional replacement on your desktop, if you want to create a server, try a safe podman session.

    The very first thing that an expericend linux user do, is to kick out flatpak from your installation.

    • SigmaSquadron

      I don’t think you understand how Flatpak works. It doesn’t use your RPM packages at all. It’s meant to be self-contained, and separate from the host’s system binaries and libraries, for the express purpose of not causing version mismatches, which would happen in other packaging formats. Flatpak isn’t “dirty made” for a specific distribution either. All flatpaks run in a common runtime provided by a repo, and can be used on multiple architectures and operating systems.

      Unlike Canonical’s snaps, Flatpak does not run on servers. I don’t really understand why’d mention things like podman in this situation.

      Finally, Flatpak’s main appeal is sandboxing. Bubblewrap uses podman to create an isolated environment for each application to run in, optionally creating sandbox holes in order to access the main system. This ensures an application will not alter, use, create or delete the host system resources, including your RPM packages, which again, aren’t touched by anything on Flatpak.

    • Kaya

      It is funny how you discourage using Flatpak but praise Podman, when in essence, they follow the same core principle: Isolate an app and its dependencies from the underlying operating system.

  2. frfwertfw

    i need a matrix client and node using lora.
    when internet down i need still digital communication trought PMR, cb-Radio etc.

  3. You Really Don't Want to Know

    I read the flatpack article and the wikipedia entry on Matrix and I would not touch this stuff with a ten foot pole. YMMV.

  4. Wolfgang Maier

    I’m using that exact same setup with four different profiles and the repo https://github.com/taw00/element-rpm – so need to take the flatpak route if you don’t like it.

    One small remark about:

    A little quirk: if you already started one session with a ‐‐profile flag the original without the flag won’t start.

    That’s true, but you can right-click element in the dock and select New Window. This will open the original session without the flag.

  5. Centennial IPA

    I love Fedora, Flatpak, and Matrix. Excellent article!

  6. Sally

    By the way, Element application doesn’t support aarch64/arm64 on flathub as least, which a I think a shame, and doesn’t officially available in Fedora Repos.

  7. francesco

    Seems to me like time for software distributions is over. Now we have Linux-based systems plus an application store just like Google Android and its Play Store or Apple iOS and its App Store (I know the latter is not Linux-based). I’m not against Flatpaks or Snaps, but they should be an option if you really need software that’s not packaged in your distibution (and it may be ok in the case of this article) or if you really need a new version of a specific software because of new features available or bug fixes.

    They should not be the regular way to install applications on your system: inside these stores it’s not clear whether software is proprietary or open source because it’s all mixed up (sometimes there’s not even a license!). It’s not immediately clear who uploaded the application, if the authors of the software or a third party… you need to check these things very carefully each time you install something and the possibility of malware is not so remote in my opinion. If flatpaks and snaps are “the future of applications on Linux”, in this future you’d better save time and resources and keep the copy of Microsoft Windows that comes preinstalled on “your” computer… and use WSL if you need Linux.

    I’m so disappointed to see Canonical shipping Ubuntu with snaps by default and now Fedora seems to follow with flatpaks.

    How long will software distributions last?

    • None of what you claimed is correct. Flathub (and other flatpak repositories) must declare the license for each application, defaulting as proprietary for a project with no license. There is no mix up for regular users either, as frontends like GNOME Software make it exceedingly clear if an app is proprietary or not.

      Regarding the maintainer of the Flatpak, you can check the packager on Flathub, and compare them with the upstream maintainers. The same is true for .rpm or .deb packages, as those are often built by packagers on the distribution, and not by upstream developers.

      It’s also less likely to be infected by malware on flatpak apps because they are sandboxed, and it wouldn’t make sense for a malware developer to develop malware for a single container, without infecting the rest of the system.

  8. Khai

    I think folks have genuine concerns regarding packaging. Containers seem to be the way forward. Simple compose file to bring matrix & element up with a simple “docker compose up” instruction explained here – https://cyberhost.uk/element-matrix-setup/

  9. Khai

    Plus, better to understand Matrix’s limits before commitment. e.g. you can’t really delete users – https://github.com/matrix-org/synapse/issues/1707

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions