Bug 256648 - x11/sddm enhance xinit-session for 'User Session' to work in the absence of ~/.xinitrc
Summary: x11/sddm enhance xinit-session for 'User Session' to work in the absence of ~...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-kde (group)
URL: https://cgit.freebsd.org/ports/tree/x...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-16 15:54 UTC by Graham Perrin
Modified: 2021-07-17 22:23 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (kde)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Perrin freebsd_committer freebsd_triage 2021-06-16 15:54:06 UTC
It seems that if the logging-in user has no 
~/.xinitrc
then a User Session will (most likely) fail almost immediately: 

* the SDDM greeter will reappear. 

With /usr/local/share/sddm/scripts/xinit-session patched according to <https://invent.kde.org/-/snippets/1713>, it seems that User Session will (in the absence of an ~/.xinitrc file) succeed, reliably.
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2021-06-16 16:00:34 UTC
With /usr/local/share/sddm/scripts/xinit-session experimentally reduced to a single line: 

exec startx

– things were less successful. My test results were not entirely conclusive, but it's possible that _none_ of the tests led to a usable xterm window. 


----


Instead, from <https://invent.kde.org/-/snippets/1713> 
              (fallback in xinit-session): 

#!/bin/sh
#
# Runs the user's .xinitrc (at this point, .xsession has already
# been sourced).

RC="$HOME/.xinitrc"

if [ ! -f "$RC" ] ; then
RC=/usr/local/etc/X11/xinit/xinitrc
fi

test -x "$RC" && exec "$RC"
test -f "$RC" && exec /bin/sh "$RC"
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2021-06-16 16:06:37 UTC
(In reply to Graham Perrin from comment #1)
What's the point of putting startx into /usr/local/share/sddm/scripts/xinit-session ? That's kind of recursive.
Comment 3 Tobias C. Berner freebsd_committer freebsd_triage 2021-06-16 18:17:19 UTC
(In reply to Gleb Popov from comment #2)
yes, that was based on my idea^H misunderstanding :) "why should we figure out the proper xinitrc when startx already can do it".

But I think patching in the system xinitrc should be fine (or at least be less confusing).

mfg Tobias
Comment 4 Gleb Popov freebsd_committer freebsd_triage 2021-06-16 18:30:12 UTC
(In reply to Tobias C. Berner from comment #3)
It might have sense to add

xmessage "You are running default X session. Put whatever you want into $HOME/.xinitrc file to start something else"

to /usr/local/etc/X11/xinit/xinitrc , maybe?
Comment 5 Tobias C. Berner freebsd_committer freebsd_triage 2021-06-16 18:36:47 UTC
(In reply to Gleb Popov from comment #4)
I think getting to use twm is warning enough :P

Adding a message would force people who are happy with the default session (let's assume such a person exist) force to create their own xinitrc too.
So, I'm not sure whether that is a good thing.

But I think fixing sddm's session-script and adding a pkg-message to sddm might at least serve as enough documentation -- or while were looking at documentation: https://docs.freebsd.org/en/books/handbook/x11/#x11-wm should be updated to say "hey, if you want to use sddm's-xssesion, make sure to have an ~/.xinitrc"


mfg Tobias
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2021-06-17 01:38:33 UTC
+1 to a plainly worded package message. 

----

More than that, I would like 'User Session' (the phrase presented by SDDM) to be foolproof – if possible. 

Foolproof enough to work immediately for a new user – the product of adduser(8). 

A User Session that's so reliable – without an absolute _requirement_ for ~/.xinitrc – will be very useful as a step in basic troubleshooting. In cases where, for example, a person claims that updating or upgrading something has "broken X" or whatever. 

Ask the user to choose User Session at the SDDM login screen. Then if the result is a basic window (i.e. twm) it'll be enough for the person to understand that things are not entirely broken, next steps in troubleshooting can be more user-friendly, and so on. 

----

(Whilst cases of misunderstood 'breakage' are rare, it's not uncommon for other readers to 'jump on the bandwagon' and reach a wrong conclusion …)
Comment 7 Adriaan de Groot freebsd_committer freebsd_triage 2021-07-17 19:58:45 UTC
In order to enable using the default xinit, which runs xterm, we would need to add xinit and xterm to the dependencies of SDDM (because you could install SDDM, plus xorg-server, and skip xorg-apps entirely).

I can imagine a slightly different setup, which depends on xmessage only; it would check for .xinitrc in $HOME, the default xinit, and then fall back to just xmessage. And a pkg-message: someone who hasn't installed xinit (and xterm and twm) and still expects SDDM to magically do the right thing with undefined user sessions can be expected to handle an xmessage.
Comment 8 commit-hook freebsd_committer freebsd_triage 2021-07-17 22:22:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=87b48b8d60d42f77e3cea05610bbb5dde23ec896

commit 87b48b8d60d42f77e3cea05610bbb5dde23ec896
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2021-07-17 22:12:57 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2021-07-17 22:21:59 +0000

    x11/sddm: make "user session" more resilient

    It's possible to install SDDM with very little other X11 baggage,
    like xterm. In such a minimal install situation, SDDM will still
    come up and offer "User Session" -- and that session will fail,
    because there's nothing to run.

    Depend on xmessage, and then fall back to xinit's default script
    and if **that** isn't there, show the user a message instead of
    just sitting there with a black screen and an X cursor.

    PR:             256648
    Reported by:    Graham Perrin

 x11/sddm/Makefile            |  7 +++++--
 x11/sddm/files/xinit-session | 22 ++++++++++++++++------
 x11/sddm/pkg-message         |  7 +++++++
 3 files changed, 28 insertions(+), 8 deletions(-)