ReGreet
ReGreet copied to clipboard
Create an X server for X11 sessions
This resolves #15 by prepending startx /bin/env
to X11 session commands, to start an X server for an X11 session. Note that this assumes the existence of the startx
and /bin/env
commands.
Further, since this is only to be done for X11 sessions, this PR separates the SESSION_DIRS
environment variable into WAYLAND_SESSION_DIRS
and XSESSION_DIRS
, since there's no way of knowing this from the session file itself.
@TLATER, since you seem to be a lot more familiar with this than me, can you test this and see if it works for your cases (and any other potential ones)?
EDIT: Also resolves #31.
I'll test it, might be a day or two before I get around to it. From a quick glance, I'm not sure if startx
starts the X server as expected. Its behavior tends to be a bit distro specific.
Lightdm & co also put a lot of effort into passing session status to the X server. I'm not 100% sure what said status is actually needed for though, so let's see!
Hrm, startx
apparently explicitly behaves differently from display managers starting X servers, because the xorg project once upon a time decided there should be an xdm
that can handle sessions across multiple computers and an xinit
which only handles local sessions.
The two source different configuration files for the running X server, because xdm
just talks the X protocol and makes the (potentially remote) session appear in the X server it is part of, whereas xinit
(and hence startx
) are there to just launch the X server.
Ultimately this boils down to startx
sometimes launching an unexpected xterm instead of the command you give it, depending on what files you have in your home directory, and ignoring the user's xsession
.
I've spent some time delving into the details of how lightdm/gdm actually launch to see what a display manager is actually supposed to do so I can suggest (and perhaps implement myself) an alternate approach, but haven't yet fully figured it out. Regardless, this has definitely convinced me even more to get rid of my X sessions as soon as possible.
Just dropping my 2 cents here: startx /etc/X11/Xsession
might work better than startx /bin/env
, or at least might be worth trying.
From what I was able to understand, /etc/X11/Xsession
loads configuration snippets from /etc/X11/Xsession.d. More importantly, if invoked without an argument or with an invalid one, it falls back to executing ~/.xsession, which is how some users bring up a minimal WM instead of a DE. For example, LightDM's "Default XSession" entry contains exec=default
, but default
isn't a valid executable so it ends up launching .xsession instead.
Just dropping my 2 cents here: startx /etc/X11/Xsession might work better than startx /bin/env, or at least might be worth trying.
What distro are you using? Arch doesn't have that file.
I'm using Debian testing. The session file is /usr/share/xsessions/lightdm-xsession.desktop
and it is installed by the lightdm
package. This is its content:
[Desktop Entry] Version=1.0 Name=Default Xsession Exec=default Icon= Type=Application
Further, since this is only to be done for X11 sessions, this PR separates the SESSION_DIRS environment variable into WAYLAND_SESSION_DIRS and XSESSION_DIRS, since there's no way of knowing this from the session file itself.
Ugh... this really isnt necessary because what you do is: (complicated steps) that evaluate to:
- get XDG_DATA_DIRS
- unwrap_or(/usr/share)
- for each path in
:
separated list from that var, append /xsessions, /wayland-sessions. Then map over them with a glob (which really isn't neccessary, you can write this glob in 5-ish lines of .map() and std DirEntry functions) - compile regexes in a loop. (you are supposed to do Regex::new outside the loop)..... (this issue is probably out of scope for this PR.
Also, umm, a default value for xdg data dirs is in the xdg spec. An override is done via a (program's runtime) env variable. I don't understand the logic of overriding the doc-defined default at compile time.
Also the current spec defines the default as this:
If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
If an environment variable is either not set or empty, its default value as defined by this specification should be used instead.
https://specifications.freedesktop.org/basedir-spec/latest/
So that should probably be fixed too.