Jan Grulich

Telegram desktop client for flatpak #2

Some time ago I posted a blog post about how I packed telegram desktop client for flatpak. I’ve been updating it since then in some reasonable intervals as I don’t have time to update it more often and mostly because the telegram client’s build system breaks my build quite oftenly. Recently I discovered that someone managed to patch telegram to use system Qt libraries instead of building own patched Qt and building linking it statically. After some time I managed to adjust those patches and make them work with my build which allows me to use Qt from KDE runtimes. Here are new instructions how to get this work:

Add KDE runtimes repository and install runtimes
$ flatpak remote-add kde --from https://distribute.kde.org/kderuntime.flatpakrepo
$ flatpak install kde org.kde.Platform

And then you can install and run the telegram desktop client:
$ wget https://jgrulich.fedorapeople.org/telegram/keys/telegram.gpg
$ flatpak remote-add --gpg-import=telegram.gpg telegram-desktop https://jgrulich.fedorapeople.org/telegram/repo/
$ flatpak install telegram-desktop org.telegram.desktop
$ flatpak run org.telegram.desktop

Or install it from bundle
$ wget https://jgrulich.fedorapeople.org/telegram/telegram.flatpak
$ flatpak install --bundle telegram.flatpak

The reason I did the hard work to build it with Qt from KDE runtimes is that now you can use telegram with portals support if you run it with “-platform flatpak” parameter. Unfortunately this only makes openURI portal to work as telegram has some internal hacks or whatever to use gtk filedialog so for that reason I still allow to access user’s home directory. There is also a bug if you use telegram under KDE where it tries to use QSystemTrayIcon instead of libappindicator and unfortunately telegram’s system tray icon (the one using QSystemTrayIcon) works only with Qt 5.6.2 and in KDE runtimes we have Qt 5.7.1. The system tray icon is visible, but its context menu doesn’t work so if you want to have fully working system tray icon you have to use “–env=XDG_CURRENT_DESKTOP=gnome” flatpak parameter to force it to use libappindicator.

And that’s it. Sorry you had telegram broken for couple of days while I was fighting with it, but hopefully it will work perfectly now.

31 thoughts on “Telegram desktop client for flatpak #2

    1. Sure, but I would need better description about your problem. Do you get any error when you run it using “flatpak run … “?

      1. Sure, I was wondering if you prefer it e.g. somewhere github.

        Now, I have kinda uncommon setup so it’s probably something rare.

        I have binary nvidia drivers (hence libGL errors – I get that from other flatpaks as well but they work),
        And I don’t have pulseaudio. Looks like telegram fails to use alsa.

        Binary non-flatpak version works on the same machine, so it might be some flatpak restriction?

        $ flatpak run org.telegram.TelegramDesktopDevel
        libGL error: No matching fbConfigs or visuals found
        libGL error: failed to load driver: swrast

        ** (telegram-desktop:2): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
        AL lib: (WW) alc_initconfig: Failed to initialize backend “pulse”
        ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

        AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device ‘default’: Connection refused
        : CommandLine Error: Option ‘bb-vectorize-ignore-target-info’ registered more than once!
        LLVM ERROR: inconsistency in registered CommandLine options

        1. I’ve been told that you are missing nvidia driver extension or there is an issue with it and kde runtime. Also you don’t have pulseaudio and there is now libalsa with direct HW access.

  1. Hi… thanks. Telegram desktop client for flatpak is working nicely, but I have some issues with it:
    1. When I launch Telegram, always a new instance is created, that means I can launch Telegram twice and have two of them at the same time!
    2. When I click on URLs in Telegram, they are not opening in the browser (nothing happens).
    3. How can I change the name of the launcher in applications menu? I want to change “(Nightly) Telegram Desktop” to “Telegram Desktop (Nightly Build)”

    1. I should correct case 3! Where is the path of Telegram .desktop file? I am using Debian but I couldn’t find it anywhere.

      1. OK, I found it in “/var/lib/flatpak/exports/share/applications/”.

    2. 1) I think this should be fixed now, please update telegram
      2) Should work now when you open telegram through desktop file
      3) Nightly suffix is now gone

      1. 1) Yes, it is fixed.
        2) .desktop file cannot launch Telegram, I tested its “Exec” command in Terminal:
        “/usr/bin/flatpak run –branch=master –arch=x86_64 –command=telegram-desktop org.telegram.desktop — -platform flatpak”
        but it didn’t work, this is the error-message:
        “ASSERT failure in QList::at: “index out of range”, file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 540″
        but if I remove “-platform flatpak” argument, it will launch Telegram (of course when I click on URLs in Telegram, they are not opening in the browser (nothing happens)):
        “/usr/bin/flatpak run –branch=master –arch=x86_64 –command=telegram-desktop org.telegram.desktop –”
        Thanks.

          1. I updated Telegram with the following command:
            “$ flatpak update”
            but still .desktop file does not work (with “-platform flatpak” argument):
            “ASSERT failure in QList::at: “index out of range”, file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 540″

          2. Sorry, my fault, there is apparently something still missing. I will look into that as soon as possible. Meanwhile use –env=XDG_CURRENT_DESKTOP=KDE flatpak paramater as a workaround. Unfortunately there is side effect of using telegram under KDE, that is not using libappindicator and thus not working context menu in systemtray icon.

    3. I am using Debian Testing + GNOME, this command didn’t work (“–env=XDG_CURRENT_DESKTOP=KDE” argument):
      “$ /usr/bin/flatpak run –branch=master –arch=x86_64 –command=telegram-desktop org.telegram.desktop –env=XDG_CURRENT_DESKTOP=KDE — -platform flatpak”
      and still the problem is “-platform flatpak” argument and prints the same error message:
      “ASSERT failure in QList::at: “index out of range”, file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 540″
      I had installed Telegram via the following command:
      “$ flatpak install –from https://jgrulich.fedorapeople.org/telegram/telegram.flatpakref
      Thanks.

      1. Try it now please, I workarounded this problem by forcing KDE platform theme instead of gnome one which is not working at this moment, this won’t have any sideeffect as telegram has lots of its own custom stuff anyway.

        1. Same for me.. still not working with the parameter -platform flatpak

          Gtk-Message: Failed to load module “pk-gtk-module”
          Gtk-Message: Failed to load module “canberra-gtk-module”
          Gtk-Message: Failed to load module “pk-gtk-module”
          Gtk-Message: Failed to load module “canberra-gtk-module”
          ASSERT failure in QList::at: “index out of range”, file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 540

          I am using Fedora 25 Workstation

  2. I have the same problem as M. Sadeq H. E.
    if i remove the -platform flatpak argument it works fine.

    Best regards,

    1. It is only available in the Russian Fedora Repo..
      Anyway.. i’d like to have it in a sandboxed flatpak environment

  3. Now, without the platform parameter in the desktop starter it is working again. thank you for removing it! And keep on your good work!

  4. Hello Jan,

    Thanks for flatpak-ing this app.

    I’ve installed through the bundle (with –user). I have checked I have installed the kde and telegram-desktop flatpak remotes but, when I run, I get:

    $ flatpak run org.telegram.desktop
    telegram-desktop: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory

    Hope you can get a look to this.

  5. It works now, but there is yet another small problem. It won’t run from the desktop launcher. I checked:

    $HOME/.local/share/flatpak/exports/share/applications/org.telegram.desktop.desktop

    And it seems the application is launched like:

    $ /usr/bin/flatpak run –branch=master –arch=x86_64 –command=telegram-desktop org.telegram.desktop — -platform flatpak
    Gtk-Message: Failed to load module “canberra-gtk-module”
    Gtk-Message: Failed to load module “canberra-gtk-module”
    ASSERT failure in QList::at: “index out of range”, file ../../../../include/QtCore/../../src/corelib/tools/qlist.h, line 540

    So, it coredumps. However, it works if I just run it like:
    $ /usr/bin/flatpak run –branch=master –arch=x86_64 –command=telegram-desktop org.telegram.desktop — -platform xcb
    Gtk-Message: Failed to load module “canberra-gtk-module”
    Gtk-Message: Failed to load module “canberra-gtk-module”

    Or just:

    $ flatpak run org.telegram.desktop
    Gtk-Message: Failed to load module “canberra-gtk-module”
    Gtk-Message: Failed to load module “canberra-gtk-module”

  6. Telegram opens for me, but as soon as I push any key, it crashes, with the message:

    ASSERT: “uint(i) < uint(size())" in file ../../../../include/QtCore/../../src/corelib/tools/qstring.h, line 897

  7. The latest version of Telegram desktop client for flatpak is working nice in GNOME:
    1. When I launch Telegram, if I launch it again, it does not create a new instance.
    2. When I click on URLs in Telegram, they are opening in the browser.
    3. It does not crash when I use telegram with portals support (It is by default without the need to specify “-platform flatpak” argument).
    Thanks 🙂

  8. Hi, I don’t know if this thread is still open, and I don’t know if what to me seems a bug is, in fact a feature. If it is a feature, pardon me.
    Thing is, when I try to attach a file using Telegram it only displays directories ~/Image, ~/Documents, ~/Downloads and a few “standard” others. Nevertheless, I have many other directories at ~/. In fact, my data resides at Dropbox and they appear to me at ~/Dropbox. It seems Telegram does not allow me to see them.

    Is there a way to fix this (if it is a bug) or to change this (if it is a programmend behaviour)?

Leave a Reply to Kevin Kofler Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll To Top