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

Create an X server for X11 sessions #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Create an X server for X11 sessions #16

wants to merge 4 commits into from

Conversation

rharish101
Copy link
Owner

@rharish101 rharish101 commented Mar 25, 2023

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.

@TLATER
Copy link

TLATER commented Mar 27, 2023

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!

@TLATER
Copy link

TLATER commented Mar 30, 2023

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.

src/sysutil.rs Outdated
Comment on lines 48 to 57
let mut sessions = Self::init_sessions(
XSESSION_DIRS,
"xsessions",
&vec!["startx".into(), "/bin/env".into()],
)?;
sessions.extend(Self::init_sessions(
WAYLAND_SESSION_DIRS,
"wayland-sessions",
&Vec::new(),
)?);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to look at would be adding support for running e.g. Cage and starting Xwayland rootful to use X sessions :)

@livanh
Copy link

livanh commented Sep 30, 2023

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.

@rharish101
Copy link
Owner Author

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.

@livanh
Copy link

livanh commented Oct 6, 2023

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

- Prepend `startx /bin/env` to X11 session commands
- Separate `SESSION_DIRS` environment variable into
  `WAYLAND_SESSION_DIRS` and `XSESSION_DIRS`, since there's no way of
  knowing this from the session file itself
`SESSION_DIRS` has been removed, so have to bump version.
@rharish101 rharish101 mentioned this pull request Aug 13, 2024
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

Successfully merging this pull request may close these issues.

Automatically set XDG_SESSION_TYPE based on session file location X sessions don't launch Xorg
4 participants