Search code examples
gtkgtkmmwaylandflatpak

Flatpak on wayland error "cannot open display: "


Whenever I try to run any Gtk+ Flatpak-ed app on wayland I get error such as: (porto:3): Gtk-WARNING **: 00:55:13.780: cannot open display: :99.0 (setzer:2): Gtk-WARNING **: 01:01:41.868: cannot open display: (org.gnome.Maps:2): Gtk-WARNING **: 01:02:18.136: cannot open display:


Solution

  • The problem seems to be that GDK_BACKEND variable is for some reason set to X11. Run following commands to check whether you have the same problem. I'm using gnome maps, but you can use whichever app you like.

    flatpak run --command=sh org.gnome.Maps
    echo $GDK_BACKEND:$WAYLAND_DISPLAY:$DISPLAY
    

    Your output should be something like wayland-0,x11:wayland-0,:0.0. If it's not you should try experimenting with those variables

    export GDK_BACKEND="wayland,x11"
    export WAYLAND_DISPLAY="wayland-0"
    export DISPLAY="wayland-0"
    gnome-maps
    

    Variable changes aren't permanent and are set only until container's shell is closed.