Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screensharing not working anymore on Arch Linux with WLR 0.3.0 #117

Closed
shibumi opened this issue Apr 21, 2021 · 36 comments
Closed

Screensharing not working anymore on Arch Linux with WLR 0.3.0 #117

shibumi opened this issue Apr 21, 2021 · 36 comments

Comments

@shibumi
Copy link

shibumi commented Apr 21, 2021

Helllo,
since the update on xdg-desktop-portal-wlr 0.3.0 screen sharing stopped working for me.
Everything is setup for the tool, but it looks like dbus activation fails.

If I start up wlr manually via: /usr/lib/xdg-desktop-portal -r & /usr/lib/xdg-desktop-portal-wlr -r -l DEBUG -o DP-5

I am able to share my screen, but normally this should start up automatically via dbus, right?

@emersion
Copy link
Owner

Have you read https://github.com/emersion/xdg-desktop-portal-wlr/wiki/%22It-doesn't-work%22-Troubleshooting-Checklist?

@columbarius
Copy link
Collaborator

We added support for a config file and an output chooser. If you only want to share the DP-5 screen, please try to add a configfile to
~/.config/xdg-desktop-portal-wlr/config or /etc/xdg/xdg-desktop-portal-wlr/config
with

[screencast]
output_name=DP-5
chooser_type=none

@depate
Copy link

depate commented Apr 21, 2021

Not sure if this issue is related, however:

I encountered a similar-ish misbehavior. Starting xdg services via systemd-services automatically the error:

Apr 21 15:42:19 T480s xdg-desktop-portal-wlr[33880]: 2021/04/21 15:42:19 [ERROR] - wayland: failed to connect to display
Apr 21 15:42:19 T480s systemd[1885]: xdg-desktop-portal-wlr.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 15:42:19 T480s systemd[1885]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Apr 21 15:42:19 T480s systemd[1885]: Failed to start Portal service (wlroots implementation).
Apr 21 15:42:19 T480s systemd[1885]: xdg-desktop-portal-wlr.service: Scheduled restart job, restart counter is at 6.
Apr 21 15:42:19 T480s systemd[1885]: Stopped Portal service (wlroots implementation).
Apr 21 15:42:19 T480s systemd[1885]: xdg-desktop-portal-wlr.service: Start request repeated too quickly.
Apr 21 15:42:19 T480s systemd[1885]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Apr 21 15:42:19 T480s systemd[1885]: Failed to start Portal service (wlroots implementation).

occured. If I used the manual start however it worked flawlessly.

I found your debugging guide above. I tested all the environment variables accordingly. However in step 5 I never got the correct result regarding XDG_CURRENT_DESKTOP back despite the fact that it's basically everywhere defined.

So I followed your "hint" to add the environment variable directly to the user service xdg-desktop-portal.service at usr/lib/systemd/user/ in my system.

I had to restart and re-login for some strange reason because systemctl daemon-reload and systemctl --user daemon-load had no effect, but after this it worked. Trivially the step 5 check still returns empty.

So my question to @emersion would be, is there a chance that xdg fails to recognize the systemd user and system environment variables, e.g. if they are set via systemd-environment.d? Again, manually the start of xdg-desktop-portal-wlr works because all envvars are correctly set in the shell.

p.s. I am not sure, but this issue occured in 0.2 as well. I updated in mid debugging. I can try to roll back if you want me to check.

@danshick
Copy link
Collaborator

We've struggled to reliably instruct people how to run xdp with the correct environment for a long time. I wrote this wiki page to explain the issue in detail, but I'm afraid even with the TL;DR, it is confusing and not something people are finding when they experience issues. https://github.com/emersion/xdg-desktop-portal-wlr/wiki/systemd-user-services,-pam,-and-environment-variables

The wiki page emersion linked to covers more issues, and is more comprehensive, so maybe that will be more helpful for folks. I also like that it gives commands for testing the actual envvars that xdp is aware of.

I'm wondering if we can't still do better. Maybe a warning in the README and/or the new man pages. Maybe the wiki documents we have need to be edited/shortened/made clearer/etc.

The idea of editing the xdp service definition is not something I would suggest. At bare minimum, I'd override it using systemctl edit xdg-desktop-portal.service instead of modifying the installed service definition directly. Either way, this would break the behavior of other compositors installed on the same system.

@depate
Copy link

depate commented Apr 21, 2021

Thanks, @danshick!

I admit that I did not look any further through the wiki sites. That's my pity. Excuse me.

I know, and that's why I started investigating further initially, that's not the smartest idea to fiddle around with package provided service files manually. They are that way for a reason. I am on your site here.
I am eager to help you out with better instructions, as I struggled even as a more experienced Linux/Wayland user, once I understand the following:

You are referring to the systemd-environment declaration. I've set up all my user environment variables through my .config/environment.d/*.conf files. If I check what systemd-variables are set through a shell with systemctl --user show-environment, all necessary variables for xdp(w) are present.

Is my assumption wrong, that exactly these user variables should be present when systemd starts my user services, e.g. xdg-desktop-portal.service after login and consecutive start of SwayWM with sway in tty?
(I am lacking a LoginManager, I have only one WM, for me it's fine to hardcode the XDG_CURRENT_DESKTOP=sway and I understand, that this should be better set by a startup/LoginManager script, if multiple desktops are possibly present. Hence your tl;dr comment on your wiki site, I guess)

If not, why fails step 5 of the debug guide and the xdg service misses the important XDG_CURRENT_DESKTOP variable but not the others?

If so, I definitely have not understood the dependencies and inner workings entirely yet.

@danshick
Copy link
Collaborator

danshick commented Apr 21, 2021

I would have expected environment variables to be configured correctly if they are present using the show-environment subcommand of systemctl as you suggest. All I can suggest with regards to this is that you triple-check your spelling of all variables and that the values are as intended. Feel free to paste the output of show-environment here.

Still, we suggest not using this approach either as it will apply to any shell the user starts. You may only use one shell/wm/etc. but the alternative approach works for all use cases including folks that may also use gnome or kde or others. That involves writing yourself a small wrapper script that you use to invoke sway/river/wayfire/etc. and setting your envvars in that script prior to launching your shell. Then, we suggest exec'ing systemctl to import your environment variables in your sway config like this...

exec "systemctl --user import-environment"

@danshick
Copy link
Collaborator

Actually, everyone here seems to have the same issue of the WAYLAND_DISPLAY envvar being set wrong, not XDG_CURRENT_DESKTOP. This value is always set by sway itself and can't be known when writing a wrapper script or a systemd-environmentd config and must be "imported" after the compositor has started. What I wrote in the comment above should still fix your issue, the suggested sway config exec line specifically.

@depate
Copy link

depate commented Apr 21, 2021

I'll setup a wrapper later.

I am not sure if I understand your:

Actually, everyone here seems to have the same issue of the WAYLAND_DISPLAY envvar being set wrong, not XDG_CURRENT_DESKTOP. This value is always set by sway itself and can't be known when writing a wrapper script or a systemd-environmentd config and must be "imported" after the compositor has started.

correctly. Is WAYLAND_DISPLAY or XDG_CURRENT_DESKTOP set by sway/compositor?

I removed the environment variable from the service file and it seems to work now as well. However step 5 from the debug guide still empties out.

My systemctl --user show-environment after login and sway and the exec "systemctl --user import-environment" in sway config shows:

GDK_BACKEND=wayland
SDL_VIDEODRIVER=wayland
ECORE_EVAS_ENGINE=wayland_egl
QT_WAYLAND_DISABLE_WINDOWDECORATION=1
QT_WAYLAND_FORCE_DPI=physical
QT_QPA_PLATFORM=wayland
BEMENU_BACKEND=wayland_egl
XDG_SESSION_TYPE=wayland
MOZ_ENABLE_WAYLAND=1
XDG_CURRENT_DESKTOP=sway
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0
I3SOCK=/run/user/1000/sway-ipc.1000.117796.sock
MOTD_SHOWN=pam
OLDPWD=/home/patrik/.config/environment.d
STARSHIP_SHELL=zsh
SWAYSOCK=/run/user/1000/sway-ipc.1000.117796.sock
TERM=linux
WAYLAND_DISPLAY=wayland-1
XCURSOR_SIZE=24
XDG_SEAT=seat0
XDG_SESSION_CLASS=user
XDG_SESSION_ID=9
XDG_VTNR=1
ZSH=/home/patrik/.oh-my-zsh
_=/usr/bin/systemctl

I tried to thin out the output.

environment.d/Wayland.conf:

GDK_BACKEND=wayland
SDL_VIDEODRIVER=wayland
ECORE_EVAS_ENGINE=wayland_egl
QT_WAYLAND_DISABLE_WINDOWDECORATION=1
QT_WAYLAND_FORCE_DPI=physical
QT_QPA_PLATFORM=wayland
BEMENU_BACKEND=wayland_egl
XDG_CURRENT_DESKTOP=sway
XDG_SESSION_TYPE=wayland
MOZ_ENABLE_WAYLAND=1

@danshick
Copy link
Collaborator

Importantly WAYLAND_DISPLAY is there (which sway sets itself) and XDG_CURRENT_DESKTOP is there (which you should set in a wrapper script that you use to start sway).

Sway does not set XDG_CURRENT_DESKTOP because it was not standardized until 2017 (https://specifications.freedesktop.org/desktop-entry-spec/latest/apes03.html) and some applications (wrongly) insist on a specific value to work correctly, even if that value does not match the window manager/desktop environment/compositor you are using.

@shibumi
Copy link
Author

shibumi commented Apr 21, 2021

@depate Actually I had xdg-desktop-portal-wlr running with just environment.d environment variables:

> cat ~/.config/environment.d/envvars.conf
XDG_CURRENT_DESKTOP=sway
XDG_SESSION_TYPE=wayland

This has been my hack to import the systemd environment variables in the user shell sessions as well:

> cat ~/.zshrc.local
# .....
# Source environment variables
eval $(sed 's/^/export /' $HOME/.config/environment.d/envvars.conf)

And when I do printenv I see all variables.

But still xdg-desktop-portal-wlr.service won't start for me. So I checked the logs and I saw this:

❯ systemctl status --user xdg-desktop-portal-wlr
○ xdg-desktop-portal-wlr.service - Portal service (wlroots implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-wlr.service; static)
     Active: inactive (dead)

Apr 21 21:51:42 motoko.shibumi.dev systemd[2104]: Starting Portal service (wlroots implementation)...
Apr 21 21:51:42 motoko.shibumi.dev xdg-desktop-portal-wlr[94792]: 2021/04/21 21:51:42 [ERROR] - wayland: failed to connect to display
Apr 21 21:51:42 motoko.shibumi.dev systemd[2104]: xdg-desktop-portal-wlr.service: Main process exited, code=exited, status=1/FAILURE
Apr 21 21:51:42 motoko.shibumi.dev systemd[2104]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Apr 21 21:51:42 motoko.shibumi.dev systemd[2104]: Failed to start Portal service (wlroots implementation).
Apr 21 21:51:43 motoko.shibumi.dev systemd[2104]: xdg-desktop-portal-wlr.service: Scheduled restart job, restart counter is at 5.
Apr 21 21:51:43 motoko.shibumi.dev systemd[2104]: Stopped Portal service (wlroots implementation).
Apr 21 21:51:43 motoko.shibumi.dev systemd[2104]: xdg-desktop-portal-wlr.service: Start request repeated too quickly.
Apr 21 21:51:43 motoko.shibumi.dev systemd[2104]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Apr 21 21:51:43 motoko.shibumi.dev systemd[2104]: Failed to start Portal service (wlroots implementation).

Well, well.. this seems to be the reason why I can't share my screen anymore. I tried resetting the failure with:

systemctl reset-failed --user xdg-desktop-portal-wlr

but same behavior. I couldn't start up the screensharing. Hence I tried setting a xdg-desktop-portal-wlr as suggested by @columbarius:

❯ cat .config/xdg-desktop-portal-wlr/config
[screencast]
output_name=
max_fps=30
chooser_cmd="slurp -f %o -o"
chooser_type=simple

This doesn't work as well.. Before version 0.3.0 everything was fine, with version 0.3.0 it stopped working and I would really like to know why.

@danshick
Copy link
Collaborator

danshick commented Apr 21, 2021

@shibumi Can you share the output of systemctl --user show-environment?

Edit:
...or even better, cat /proc/$(pidof xdg-desktop-portal)/environ

@shibumi
Copy link
Author

shibumi commented Apr 21, 2021

@danshick Yes, will do, but I need to reboot my laptop because xdg-desktop-portal-wlr somehow managed to crash my dbus and my chromium:

Apr 21 22:03:18 motoko.shibumi.dev systemd[1]: user@1000.service: Failed with result 'core-dump'.
Apr 21 22:03:20 motoko.shibumi.dev systemd-coredump[98697]: Process 2962 (chromium) of user 1000 dumped core.

brb rebooting

@shibumi
Copy link
Author

shibumi commented Apr 21, 2021

@danshick

❯ systemctl --user show-environment
HOME=/home/chris
LANG=en_US.UTF-8
LOGNAME=chris
MAIL=/var/spool/mail/chris
PATH=/usr/local/bin:/usr/bin
SHELL=/usr/bin/zsh
SYSTEMD_EXEC_PID=2245
USER=chris
XDG_RUNTIME_DIR=/run/user/1000
EDITOR=nvim
PAGER=less
SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket
IBUS_SOCK=/run/user/1000/ibus.socket
TERM=xterm-256color
GOPATH=/home/chris/go
GOBIN=/home/chris/go/bin
_JAVA_AWT_WM_NONREPARENTING=1
_JAvA_OPTIONS=$'-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true'
JAVA_FONTS=/usr/share/fonts/TTF
KUBECONFIG=$'$(find ~/.kube/configs/ -type f -exec printf \'%s:\' \'{}\' +)'
XDG_CURRENT_DESKTOP=sway
XDG_SESSION_TYPE=wayland
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
❯  cat /proc/$(pidof xdg-desktop-portal)/environ
HOME=/home/chrisLANG=en_US.UTF-8LOGNAME=chrisMAIL=/var/spool/mail/chrisPATH=/usr/local/bin:/usr/binSHELL=/usr/bin/zshSYSTEMD_EXEC_PID=4370USER=chrisXDG_RUNTIME_DIR=/run/user/1000EDITOR=nvimPAGER=lessSSH_AUTH_SOCK=/run/user/1000/ssh-agent.socketIBUS_SOCK=/run/user/1000/ibus.socketTERM=xterm-256colorGOPATH=/home/chris/goGOBIN=/home/chris/go/bin_JAVA_AWT_WM_NONREPARENTING=1_JAvA_OPTIONS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=trueJAVA_FONTS=/usr/share/fonts/TTFKUBECONFIG=$(find ~/.kube/configs/ -type f -exec printf '%s:' '{}' +)XDG_CURRENT_DESKTOP=swayXDG_SESSION_TYPE=waylandDBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busMANAGERPID=2245INVOCATION_ID=ae778e8f57ef433cb7264bd02ba07d8bJOURNAL_STREAM=8:32292

The chromium monitor chooser remains grey.. and xdg-desktop-portal-wlr seems to ignore my configuration. There is no slurp being activated. systemctl status --user xdg-desktop-portal-wlr:

× xdg-desktop-portal-wlr.service - Portal service (wlroots implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-wlr.service; static)
     Active: failed (Result: exit-code) since Wed 2021-04-21 22:15:52 CEST; 1min 38s ago
    Process: 4392 ExecStart=/usr/lib/xdg-desktop-portal-wlr (code=exited, status=1/FAILURE)
   Main PID: 4392 (code=exited, status=1/FAILURE)
        CPU: 2ms

Apr 21 22:15:51 motoko.shibumi.dev systemd[2245]: Failed to start Portal service (wlroots implementation).
Apr 21 22:15:52 motoko.shibumi.dev systemd[2245]: xdg-desktop-portal-wlr.service: Scheduled restart job, restart counter is at 5.
Apr 21 22:15:52 motoko.shibumi.dev systemd[2245]: Stopped Portal service (wlroots implementation).
Apr 21 22:15:52 motoko.shibumi.dev systemd[2245]: xdg-desktop-portal-wlr.service: Start request repeated too quickly.
Apr 21 22:15:52 motoko.shibumi.dev systemd[2245]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Apr 21 22:15:52 motoko.shibumi.dev systemd[2245]: Failed to start Portal service (wlroots implementation).

@danshick
Copy link
Collaborator

danshick commented Apr 21, 2021

@shibumi

From your logs:

Apr 21 21:51:42 motoko.shibumi.dev xdg-desktop-portal-wlr[94792]: 2021/04/21 21:51:42 [ERROR] - wayland: failed to connect to display

xdpw is exiting with an error code because it cannot connect to wayland. It isn't even running long enough to read your config or activate slurp or respond to chromium's d-bus messages.

You have XDG_CURRENT_DESKTOP in there, but you do not have WAYLAND_DISPLAY. You are going to have to include exec "systemctl --user import-environment" in your sway config.

If you only want to import the WAYLAND_DISPLAY variable and not all currently set variables, you could use exec "systemctl --user import-environment WAYLAND_DISPLAY" instead.

@shibumi
Copy link
Author

shibumi commented Apr 21, 2021

@danshick After setting exec "systemctl --user import-environment" in my sway config I have the same behavior + even when I check the environ of sway the WAYLAND_DISPLAY variable is missing.

It looks like my sway is not setting the WAYLAND_DISPLAY variable oO but when I do printenv I see the variable: WAYLAND_DISPLAY=wayland-1.

Funny. When I execute systemctl --user show-environment the variable is there. Is it possible that sway is too fast and the variable is not being set yet when it starts and exports the environment?

@danshick
Copy link
Collaborator

danshick commented Apr 21, 2021

@shibumi

It won't be in sway's environment because sway sets this variable, it isn't started with it. I can confirm this on my own system. Edit: a process's environment is fixed once the process is started (unless you use gdb or other hacks)

What is likely happening is that xdg-desktop-portal is surviving between sway sessions. If you've added that line to your sway config, try running pkill -f xdg-desktop-portal and then restarting sway without attempting any screen shares between those two steps. It might help to completely close sway and reopen it (because I don't always remember the differences between doing that and simply reloading the config). Better still would be to log all the way out of your TTY session. If you do so and wait for all user owned processes to terminate, you ensure a fresh systemd user session.

@shibumi
Copy link
Author

shibumi commented Apr 21, 2021

@danshick Thank you, Thank you Thank you! This was it! Looks like I forgot to kill my xdg-desktop-portal session.

Just out of curiosity, since when is this WAYLAND_DESKTOP variable needed? I never set this before 0.3.0

@shibumi shibumi closed this as completed Apr 21, 2021
@danshick
Copy link
Collaborator

There have been no relevant changes to xdpw that would affect this. Maybe sway is handling this differently as of late? Couldn't say for sure but maybe @emersion has some idea.

@emersion
Copy link
Owner

You mean WAYLAND_DISPLAY? Sway changed the default, but iirc that happened in Sway 1.5.

@danshick
Copy link
Collaborator

Hmmm, that doesn't line up.

@sauliusvl
Copy link

Same issue here on two separate machines, went away after downgrading sway/wlroots to 1.5.1/0.12.0. If I had to guess there's some issue with setting WAYLAND_DISPLAY during sway initialization? because waybar also stopped working on startup due to the same reason (could not determine the display), only worked if I re-launch it later from the terminal, also fixed by downgrading.

@shibumi
Copy link
Author

shibumi commented Apr 22, 2021

@sauliusvl quickfix is adding exec "systemctl --user import-environment" to your sway config.

@danshick
Copy link
Collaborator

@sauliusvl quickfix is adding exec "systemctl --user import-environment" to your sway config.

Just want to clarify, doing this only helps applications that are launched as systemd user session services. Most people using apps like waybar exec them directly from their sway config, which wouldn't be affected by using this config change.

If you do have waybar (or other wayland apps) set up as user services, you definitely do want to consider making this configuration change permanently. It is the only way to ensure that your systemd user session inherits the environment changes that you've set up or that your window manager has made.

@sauliusvl
Copy link

@sauliusvl quickfix is adding exec "systemctl --user import-environment" to your sway config.

Thanks, this does indeed fix the waybar issue too, though I'm a bit confused by the timing as apparently this has been an issue since sway 1.5:

yet it only broke after upgrading to 1.6 🤷‍♂️

@robertjk
Copy link

robertjk commented Apr 30, 2021

I read that thread today when fixing my issues with screen sharing not working. Just want to add that everything works fine on my setup without:

  • Calling exec "systemctl --user import-environment" in my Sway config
  • Setting XDG_CURRENT_DESKTOP, XDG_SESSION_TYPE nor WAYLAND_DISPLAY environment variables manually

My setup:

  • Arch Linux
  • Sway WM
  • pipewire-media-session
  • xdg-desktop-portal, xdg-desktop-portal-wlr

@danshick
Copy link
Collaborator

@robertjk

XDG_CURRENT_DESKTOP doesn't matter unless you have more than one portal implementation installed. Many people do this because the GTK and/or KDE portal implementations provide implementations for non-wlroots specific portal methods.

XDG_SESSION_TYPE only matters to browsers, and is unrelated to the correct functioning of xdpw itself. The advice you may have found to set it is a relic of a time when browsers wouldn't attempt pipewire screen sharing if they weren't aware that they were in a wayland session. It probably isn't necessary anymore but I can't say that for certain and it doesn't hurt anything to set it.

If your sway session just so happens to initialize WAYLAND_DISPLAY to wayland-0, that seems to be the default choice that the wayland libs will use when attempting to connect to wl_display instances. Any other value of WAYLAND_DISPLAY will cause you trouble. sway makes this decision with irreverence towards your configuration or preferences, and there are no guarantees that the behavior you are experiencing today will stay constant.

It is plausible that the situation you describe is true, but it is unlikely and fragile. I would suggest that you at least call exec "systemctl --user import-environment WAYLAND_DISPLAY" in your sway config to ensure that the value of WAYLAND_DISPLAY that sway sets is known by systemd user session services.

@robertjk
Copy link

@robertjk

XDG_CURRENT_DESKTOP doesn't matter unless you have more than one portal implementation installed. Many people do this because the GTK and/or KDE portal implementations provide implementations for non-wlroots specific portal methods.

XDG_SESSION_TYPE only matters to browsers, and is unrelated to the correct functioning of xdpw itself. The advice you may have found to set it is a relic of a time when browsers wouldn't attempt pipewire screen sharing if they weren't aware that they were in a wayland session. It probably isn't necessary anymore but I can't say that for certain and it doesn't hurt anything to set it.

If your sway session just so happens to initialize WAYLAND_DISPLAY to wayland-0, that seems to be the default choice that the wayland libs will use when attempting to connect to wl_display instances. Any other value of WAYLAND_DISPLAY will cause you trouble. sway makes this decision with irreverence towards your configuration or preferences, and there are no guarantees that the behavior you are experiencing today will stay constant.

It is plausible that the situation you describe is true, but it is unlikely and fragile. I would suggest that you at least call exec "systemctl --user import-environment WAYLAND_DISPLAY" in your sway config to ensure that the value of WAYLAND_DISPLAY that sway sets is known by systemd user session services.

Thanks. That's a lot of great info I wasn't aware of.

To make it clear in my environment WAYLAND_DISPLAY is automatically set to wayland-1 (maybe it's not wayland-0 because I have 2 outputs connected?) and XDG_SESSION_TYPE is set to wayland, even though I don't set those variables myself. XDG_CURRENT_DESKTOP is unset.

@emersion
Copy link
Owner

To make it clear in my environment WAYLAND_DISPLAY is automatically set to wayland-1

Maybe because you have something like include /etc/sway/config.d/* in your Sway config?

XDG_SESSION_TYPE is set to wayland

Maybe because you have a login manager?

maybe it's not wayland-0 because I have 2 outputs connected?

No, these are completely unrelated things.

@robertjk
Copy link

Maybe because you have something like include /etc/sway/config.d/* in your Sway config?

I do. That's in the default Sway config file, so I left it like this.

Maybe because you have a login manager?

I do. I use ly.

@danshick
Copy link
Collaborator

danshick commented May 1, 2021

To make it clear in my environment WAYLAND_DISPLAY is automatically set to wayland-1

Not sure why that is working OOTB for you then. Some people definitely get errors related to xdpw being unable to connect to wayland if they don't have this set in scope for systemd.

Maybe your login manager is also managing your env vars for your systemd user session. Not sure.

@emersion
Copy link
Owner

emersion commented May 1, 2021

Archlinux ships a config file with import-environment in /etc/sway/config.d/*

@robertjk
Copy link

robertjk commented May 1, 2021

Archlinux ships a config file with import-environment in /etc/sway/config.d/*

Ah, indeed!

$ cat /etc/sway/config.d/50-systemd-user.conf
# sway does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment
# See FS#63021
# Adapted from xorg's 50-systemd-user.sh, which achieves a similar goal.

exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
exec hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK

@shibumi
Copy link
Author

shibumi commented May 1, 2021

I am on Arch Linux. This must have been fixed after my posts. Interesting.

EDIT:

Ok, I had a glimpse on this. It got submitted into the package 24 days ago:

archlinux/svntogit-community@68d3ae2#diff-3e341d2d9c67be01819b25b25d5e53ea3cdf3a38d28846cda85a195eb9b7203a

I really would like to know why this is not working for me then and I had to manually include import-environment in my sway configuration?!

@robertjk
Copy link

robertjk commented May 1, 2021

I really would like to know why this is not working for me then and I had to manually include import-environment in my sway configuration?!

Do you have a line include /etc/sway/config.d/* in your Sway's config file?

@shibumi
Copy link
Author

shibumi commented May 1, 2021

@robertjk no.

@robertjk
Copy link

robertjk commented May 1, 2021

@robertjk no.

Then that is the reason, why it doesn't work for you. /etc/sway/config.d/50-systemd-user.conf is only executed, if your configuration includes that file.

It's your decision, but it might be good idea to add it. Take a look at example config at /etc/sway/config. It has that include at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants