FS#63021 - [sway] does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment
Attached to Project:
Community Packages
Opened by Sauyon Lee (sauyon) - Thursday, 27 June 2019, 12:56 GMT
Last edited by Brett Cornwall (ainola) - Thursday, 14 October 2021, 23:43 GMT
Opened by Sauyon Lee (sauyon) - Thursday, 27 June 2019, 12:56 GMT
Last edited by Brett Cornwall (ainola) - Thursday, 14 October 2021, 23:43 GMT
|
Details
Description:
Additional info: * version 1.1.1-3 I've discussed this with upstream and they think it should be in user configuration; I think that this behavior should be default in the same way that X provides this functionality with a configuration file. |
This task depends upon
Closed by Brett Cornwall (ainola)
Thursday, 14 October 2021, 23:43 GMT
Reason for closing: Implemented
Additional comments about closing: Please open a new bug rather than resurrecting old ones. Additionally, ensure that your issue is not caused by your own environment (as it appears to be).
Thursday, 14 October 2021, 23:43 GMT
Reason for closing: Implemented
Additional comments about closing: Please open a new bug rather than resurrecting old ones. Additionally, ensure that your issue is not caused by your own environment (as it appears to be).
is their suggestion for configuration; I'm not sure importing the entire environment is necessarily correct and I think something like
exec systemctl --user import-environment DISPLAY; exec systemctl --user import-environment WAYLAND_DISPLAY
would be better (for the contents of the file /etc/sway/conf.d/10-systemd.conf).
Yes. We don't want to have any configuration file specific to an init daemon in particular.
>is their suggestion for configuration
No, wiki pages are not "upstream recommendation", they are user-contributed guides. Added a note to clarify that.
>I think that this behavior should be default in the same way that X provides this functionality with a configuration file.
What does X11 do?
> I'm not sure importing the entire environment is necessarily correct
Some other env variables should probably be imported, like SWAYSOCK and XCURSOR_*.
I had remembered incorrectly; there's a file /etc/X11/xinit/xinitrc.d/50-systemd-user.sh that's owned by systemd that sets DISPLAY for user systemd, but I thought it would be a bit strange to ship systemd with separate configuration files for each of the compositors. Given that systemd is pretty built into Arch now, I think it would be sensible for the Arch packages to include init scripts in the compositor packages to set the environment variables, though that's obviously entirely up to the maintainers.
#!/bin/sh
systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY
fi
Xorg is a pretty standard display server, with exactly one place where this stuff is "expected" to be stored. The example xinitrc makes sure to source the "well-known" files here, and https://wiki.archlinux.org/index.php/Xinit#xinitrc has a note that any custom xinitrc should at least implement that sourcing.
For Xorg, the DISPLAY and XAUTHORITY files are the minimum which any applications needing to see the display server absolutely must have access to.
This is not about shipping a systemd service with sway, there is no systemd service for Xorg either. :p
However, in order for systemd services to see your manually started Xorg or sway, it is necessary to tell them where to find it.
A possibly related issue which I was pinged for, today, is https://github.com/keybase/client/issues/19614
I forgot about user services like gpg-agent.
Well, I guess it's up to the maintainers as you said.
Please confirm that it is working as expected.
Also, from what I understand, such configuration files are not expected to be shell scripts, so you should probably follow the Sway wiki page mentioned above and use Sway's exec command.
Edit: In addition, any reason you're not importing XCURSOR_THEME too?
Plus, as dbus-update-activation-environment is shipped by the dbus package which is itself required by systemd, why not use only this command with the `--systemd` option?
It's about having sway export its environment variables into systemd for use by services that may want to communicate with the sway display server.
...
The more appropriate commit would be this: https://git.archlinux.org/svntogit/community.git/commit/trunk?h=packages/sway&id=25fb6171a749a99ba9d29aa838f575f14937cab1
But, what does this even do? It's a shell script installed to /etc/sway/conf.d/10-systemd.conf, does this directory execute shell scripts? According to
FS#65267, no it does not.These do seem to be exported:
[~]$ echo $WAYLAND_DISPLAY
wayland-0
[~]$ echo $SWAYSOCK
/run/user/1000/sway-ipc.1000.1630.sock
[~]$ echo $XCURSOR_SIZE
24
In any case, it does appear that this file does *not* work, as systemctl --user show-environment does not show any of these variables. I think this should be removed.
Which isn't required for xorg to function either, but is required for some software, such as the gpg-agent, to function in combination with X.
Aside: the variable surely exist in your terminal, but I'd be more interested if e.g. this listed the variables in question
systemd-run --user /usr/bin/printenv
journalctl --user
EDIT: err yeah, that
So this software has been working despite a broken stock configuration for a while now.
>[...] Arch ships the configuration files provided by upstream with changes limited to distribution-specific issues like adjusting the system file paths.
I can see the usefulness of automatically setting this parsing up, but it feels to be a violation of Arch's principles of simplicity.
Pulling myself back brings these questions up:
* Is there any situation in which a user will not want these imported in a systemd-centric distribution like Arch?
* Will this complicate bug reports upstream?
* Will this create unexpected behavior?
I argue that the answer is "no" to all three of those, so it seems logical to keep this inclusion, especially since the precedence was set with X11.
I'll move /etc/sway/conf.d to /etc/sway/config.d and then close this task.
sway 1:1.4-2 has been uploaded to [community-staging]. This package includes this commit:
https://git.archlinux.org/svntogit/community.git/commit/trunk?h=packages/sway&id=92829209ed44389b31243b73a13f3dd8edf28178
Please test and give feedback if desired.
Thanks!
I assume sway's exec command runs the arguments in an sh shell? hash ... 2>/dev/null should work fine.
I had switched to hash because I foolishly thought that it only returned 0 or nonzero without any output and it made for a shorter line. Thanks for catching that I didn't silence stderr. I've pushed sway 1:1.4-3 to include that.
Edit: Ah, I see that the '-v' flag is necessary for command to function. I'll leave hash in as they're both POSIX tools and I'm used to using it. :)
command -v is the POSIX way to check if a command exists and show you where it is. hash is also POSIX, but its only guarantee is that hashing a command will return successfully with empty stdout if the command exists, and running hash without options will display (to stdout) implementation-defined user-readable output about the pathnames for commands that have been previously looked up and found. You're relying on the first detail, which is entirely reasonable as you don't actually care what the filepath is.
What about the second part of my comment above, regarding XCURSOR_THEME and dbus-update-activation-environment's `--systemd` option?
I'm of the opinion that theming options need not be imported at all - adding this custom behavior irks me enough, but the justification is reasonable enough that I'm willing to add it to a default system config to provide functionality required for other Arch packages to work. I'd advise customizing a user config. Regarding the --systemd flag, it seems reasonable to include, so I've done that.
I've pushed 1.4-4 to [community-staging] to reflect these changes
As for dbus-update-activation-environment's `--systemd` option, the thing is that according to the manual, it seems redundant with `systemctl --user import-environment`. My "experiments" confirm that and I've been running without the systemctl call for a long time now, thus I would remove it. But I see you're testing for the existence of the dbus-update-activation-environment command, and I'm curious: can a user be legitimately running an Arch system without dbus, as it is required by systemd itself?
Another reason for us not to ship things like this. :P
If I run commands from 50-systemd-user.conf I'm getting this error:
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1