You are not logged in.
I have exactly the same issue as outlined here: https://github.com/emersion/xdg-desktop … issues/193 which is pipewire screenshare not working because xdg-desktop-portal does not have the XDG_CURRENT_DESKTOP environment variable.
I have managed to get this working by:
systemctl --user stop xdg-desktop-portal
XDG_CURRENT_DESKTOP=sway /usr/lib/xdg-desktop-portalObviously it's not ideal, it's not deamonized and requires a terminal to be open. I'd like to get the regular systemd service working.
Anything else does not seem to work - the screenshare in Chromium does not work and I can confirm the missing environment variable is not there with `sudo cat /proc/$(pidof xdg-desktop-portal)/environ`
It's a fresh install and I can notice that Arch already includes the fixes outlined in the GitHub issues in /etc/sway/config.d/50-systemd-user.conf as below:
dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=swayI'm including the config files with `include /etc/sway/config.d/` in the user's config file.
I'm not sure if 'm using it via dbus - perhaps that's the issue?
Also running Sway with XDG_CURRENT_DESKTOP=sway sway has no effect and the environment variable is not present anywhere despite being explicitly set (weird) - it's like it's unsetting it.
Last edited by kox (2024-01-10 16:50:39)
Offline
It indeed had to be ran via dbus so the Arch config fix works.
env XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=sway dbus-run-session swayHowever, no xdg-desktop-portal-wlr does not fire from the service because of a failed condition check:
[Unit]
Description=Portal service (wlroots implementation)
PartOf=graphical-session.target
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAYI have tried starting it manually with systemctl --user start and I could see that $WAYLAND_DISPLAY is set but the logs still show the failed condition check. I'm not sure if it did work before switching to dbus (I also ran portal-wlr from the terminal earlier and yes, running the binary from the terminal does work but it's not a solution).
Update: I removed the condition and the service fails to start with an error return (there's no error message though), so it looks like indeed the systemd environment does not have the WAYLAND_DISPLAY environment variable set.
The file in /etc/sway/config.d provided by the package seems to do set it at systemd level as well:
# Upstream refuses to set XDG_CURRENT_DESKTOP so we have to.
exec systemctl --user set-environment XDG_CURRENT_DESKTOP=sway
exec systemctl --user import-environment DISPLAY \
SWAYSOCK \
WAYLAND_DISPLAY \
XDG_CURRENT_DESKTOP
exec hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY \
SWAYSOCK \
XDG_CURRENT_DESKTOP=sway \
WAYLAND_DISPLAYI don't know what's going on.
Update2:
This does start it successfully:
systemctl --user import-environment WAYLAND_DISPLAY
systemctl --user start xdg-desktop-portal-wlrSo it appears that the import executed by the config is done too early / WAYLAND_DISPLAY is set too late.
Last edited by kox (2024-01-10 15:42:33)
Offline
I have finally got a streamlined solution - I have realised that I do not need to start it automatically - I just need a convenient way to start it.
First of all, I had problems getting it to work while launching Sway via dbus - it solved the initial problem but introduced another it seems. I resorted to launching Sway normally by executing the command. It also appears that xdg-desktop-portal is started automatically despite the service being disabled and it's sort of broken so I'm starting another instance with -r
So this is my script to enable screenshare:
#!/bin/bash
# Alternatively they could be enabled but I'm not using them for anything else
systemctl --user start pipewire
systemctl --user start wireplumber
# & drops the command to the background.
# The environment variable must be set here - as I mentioned earlier, when Sway is not ran via dbus, it will be missing even when passed to sway binary while launching it.
XDG_CURRENT_DESKTOP=sway /usr/lib/xdg-desktop-portal -r & # -r is needed as xdg-desktop-portal starts on its own somehow
XDG_CURRENT_DESKTOP=sway /usr/lib/xdg-desktop-portal-wlr &Last edited by kox (2024-01-10 16:52:35)
Offline