hyprwm / Hyprland

Hyprland is a highly customizable dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
18.17k stars 757 forks source link

Xwayland applications don't startup when launching them from `nautilus` #2965

Open zeyadtamimi opened 11 months ago

zeyadtamimi commented 11 months ago

Hyprland Version

Hyprland, built from branch main at commit d20837bef8a41d6bf1732b0e8968b7f2feb9a93f

Bug or Regression?

Bug

Description

Hey,

I just started noting that on my fresh Hyprland setup that I cannot run any xwayland applications from a nautilus ( Gnome Files ) window. Unfortunately, I honestly can't remember if this is a regression or not since most of the time I just launch my applications using wofi or the terminal directly.

I am using Arch Linux and running the hyprland-nvidia-git AUR package. My startup script is as follows:

export XDG_CURRENT_DESKTOP=Hyprland
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=Hyprland

export GDK_BACKEND=wayland,x11
export QT_QPA_PLATFORM="wayland;xcb"
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland

export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export QT_AUTO_SCREEN_SCALE_FACTOR=1
export QT_QPA_PLATFORMTHEME=qt5ct

export GTK_THEME=Catppuccin-blue:dark
export GDK_BACKEND=wayland,x11

export LIBVA_DRIVER_NAME=nvidia
export __GL_GSYNC_ALLOWED=0
export __GL_VRR_ALLOWED=0
export WLR_NO_HARDWARE_CURSORS=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export GBM_BACKEND=nvidia-drm

export MOZ_ENABLE_WAYLAND=1
export MOZ_USE_XINPUT2=1

export XWAYLAND_NO_GLAMOR=1

exec Hyprland

These same environment variables are also stored in ~/.config/environment.d/envvars.conf

The actual issue can be observed in one of two ways:

1. Attempting to launch any Xwayland application From nautilus

Attempting to open an image with feh, mupdf, gimp from a nautilus which was opened via wofi or a terminal yields errors along the lines of:

feh.desktop[29705]: feh ERROR: Can't open X display. It *is* running, yeah?
mupdf.desktop[30934]: error: cannot open display
mupdf.desktop[30934]: error: aborting process from uncaught error!
gimp.desktop[31707]: Cannot open display:

All these applications work when launched from terminal or from wofi.

2. Examining environment variables for a terminal launched from nautilus

Launching an alacrity session from nautilus ( by navigating to /bin/alacritty ) I see that some of the expected environment variables are not set:

> echo $GBM_BACKEND

> echo $WAYLAND_DISPLAY
wayland-1
> echo $DISPLAY

> echo $XDG_CURRENT_DESKTOP
Hyperland

> echo $XDG_SESSION_TYPE
wayland

> echo $WLR_NO_HARDWARE_CURSORS

In fact printenv reveals that a terminal launched from nautilus has pretty much none of the expected environment variables set. This is in contrast to launching alacritty from Hyprland/wofi where all the expected parameters are set.

I am not sure if this is a red-herring.

3. Starting Nautilus From Hyprland "just works"

When starting nautilus via Hyprland through the use of keybind bind = $mainMod, H, exec, nautilus Xwayland applications launch flawlessly from it...

Which makes me very very confused.


I don't know if this constitutes a BUG in Hyprland, Nautilus, or if this is just bad environment setup on my part. But any help here would be greatly appreciated.

How to reproduce

  1. Launch a terminal application
  2. Run nautilus
  3. Try opening an Xwayland application ( e.g. opening an image with gimp )
  4. Terminal should now show an error about not being able to find a screen.

Crash reports, logs, images, videos

No response

vaxerski commented 11 months ago

sounds more like nautilus having issues with passing env. Is it just nautilus? What about dolphin? Thunar?

> echo $XDG_CURRENT_DESKTOP
Hyperland

printing actual env results instead of writing them out would be preferred.

zeyadtamimi commented 11 months ago

I think you may be right!

I tried with nemo which I understand to be a nautilus fork and that actually seemed to work with no issues.

Revisiting nautilus I also made and error and my ~/.config/environment.d/envvars.conf was not configured correctly. I have since rectified this and some more env vars are being printed through there is still a difference in variables and the issue with xwayland remains.

I have attached the printenv output for both the:

  1. Good Case: when my terminal is launched from Hyprland and can subsequently open xwayland applications
  2. Bad Case: For when my terminal is launched from nautilus which fails to open any xwayland application

For the sake of brevity I have inlined the diff between the two:

> diff --from-file bad.txt good.txt

1,3c1,3
< ALACRITTY_LOG=/tmp/Alacritty-3787.log
< ALACRITTY_SOCKET=/run/user/1000/Alacritty-wayland-1-3787.sock
< ALACRITTY_WINDOW_ID=94199170111184
---
> ALACRITTY_LOG=/tmp/Alacritty-4408.log
> ALACRITTY_SOCKET=/run/user/1000/Alacritty-wayland-1-4408.sock
> ALACRITTY_WINDOW_ID=94207996926432
6,8c6,9
< DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus,guid=8988d9ca3cb76fc86ba543ee64d9421b
< DBUS_STARTER_ADDRESS=unix:path=/run/user/1000/bus,guid=8988d9ca3cb76fc86ba543ee64d9421b
< DBUS_STARTER_BUS_TYPE=session
---
> CREDENTIALS_DIRECTORY=/run/credentials/getty@tty1.service
> DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
> DEBUGINFOD_URLS=https://debuginfod.archlinux.org
> DISPLAY=:0
14d14
< GIO_LAUNCHED_DESKTOP_FILE_PID=3787
15a16
> HYPRLAND_CMD=Hyprland
16a18
> INVOCATION_ID=156a213e50354abead8163f3d4b7ef0f
17a20
> LC_CTYPE=
22a26
> LULW=test
24,25c28
< MANAGERPID=805
< MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/dbus.service/memory.pressure
---
> MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/system.slice/system-getty.slice/getty@tty1.service/memory.pressure
26a30
> MOTD_SHOWN=pam
27a32
> MOZ_USE_XINPUT2=1
30c35
< PATH=/usr/local/bin:/usr/bin:/home/zeyadtamimi/bin:/home/zeyadtamimi/scripts:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vi-mode:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/mosh:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/cp:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/colorize:/home/zeyadtamimi/.antigen/bundles/zsh-users/zsh-syntax-highlighting
---
> PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/zeyadtamimi/bin:/home/zeyadtamimi/scripts:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vi-mode:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/mosh:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/cp:/home/zeyadtamimi/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/colorize:/home/zeyadtamimi/.antigen/bundles/zsh-users/zsh-syntax-highlighting
38c43
< SHLVL=1
---
> SHLVL=2
41c46
< SYSTEMD_EXEC_PID=814
---
> SYSTEMD_EXEC_PID=775
46,47c51,55
< WINDOWID=94199170111184
< XDG_CURRENT_DESKTOP=Hyperland
---
> WINDOWID=94207996926432
> WLR_NO_HARDWARE_CURSORS=1
> XCURSOR_SIZE=24
> XDG_BACKEND=wayland
> XDG_CURRENT_DESKTOP=Hyprland
48a57,58
> XDG_SEAT=seat0
> XDG_SESSION_CLASS=user
49a60
> XDG_SESSION_ID=1
50a62,63
> XDG_VTNR=1
> XWAYLAND_NO_GLAMOR=1
51a65
> _JAVA_AWT_WM_NONREPARENTING=1

Several DBUS_ and XDG_ env variables are either missing in the bad case or are flat out different.

zeyadtamimi commented 11 months ago

Hmmmm.

I was reading the Arch Linux Wiki regarding environment variables and one sections stood out to me: GDM and KDE Plasma source systemd user environment variables instead.

Looking at my systemd environment variables I also see that they are "difficient", so I tried running dbus-update-activation-environment --systemd --all to update the systemd environment variables vased on the wayland env variables and viola! Nautilus now works properly.

Once again for the sake of posterity I am attaching the "Good" and "Bad" case for the systemd environment variables generated by running systemctl --user show-environment:

  1. Good Case: Running dbus-update-activation-environment --systemd --all
  2. Bad Case: Straight out of a cold boot

Vaxerski, is environment variable syncing between the wayland session and systemd something Hyprland should take care of? Or is this on us to ensure by injecting into our configs?