~kennylevinsen/greetd#27: 
greetd doesn't properly handle logind TTY variable

Session registered with login should be registered with TTY=wayland not shell TTY that is currently asserted TTY=tty2

without proper TTY registration, swayidle idlehint functionality refuses to work.

Status
REPORTED
Submitter
~onigino
Assigned to
No-one
Submitted
9 months ago
Updated
5 days ago
Labels
No labels applied.

~kennylevinsen 9 months ago

Session registered with login should be registered with TTY=wayland not shell TTY that is currently asserted

No, TTY should be the controlling TTY for any physical session. The logind session type1 should be "wayland"2 (only used to change the behavior of IdleHint when the string is either "x11", "wayland" or "mir"), which is set dynamically by libseat3 if you set XDG_SESSION_TYPE before starting sway.

Maybe try setting XDG_SESSION_TYPE=wayland before starting sway and see if that does the trick? That's what I do in my sway-run, and what's mentioned in the wiki4.

~onigino 9 months ago

ok i think im missing something i followed your suggestion of a shell wrapper and my local shells in sway show the correct XDG_SESSION_TYPE=wayland

however when i run loginctl show-session x i still see a TTY=ttyX

i tried this with both gtkgreet wlgreet and tuigreet

gino

~kennylevinsen 9 months ago

however when i run loginctl show-session x i still see a TTY=ttyX

That's also correct as I mentioned in the previous comment - the logind "TTY" session variable must be set to the TTY for the VT you used to login.

It's "Type" that should be set to "wayland".

~onigino 9 months ago

Here is my current run-sway wrapper that i'm using

#!/bin/sh

# Session
eval $(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway
export XDG_CURRENT_DESKTOP=sway

systemd-cat --identifier=sway sway $@

despite this i am still getting Type=tty

loginctl show-session 34
Id=34
User=1000
Name=grey
Timestamp=Wed 2021-10-20 21:09:54 PDT
TimestampMonotonic=52962780670
VTNr=5
Seat=seat0
TTY=tty5
Remote=no
Service=login
Scope=session-34.scope
Leader=62570
Audit=34
Type=tty
Class=user
Active=yes
State=active
IdleHint=yes
IdleSinceHint=1634455784414391
IdleSinceHintMonotonic=0
LockedHint=no

also swayidle returns the following error on start

Failed to send sleep inhibit signal: Permission denied
Failed to send SetIdleHint signal: Idle hint control is not supported on non-graphical sessions.

Thanks for taking the time to help me through this.

~sorrow 2 months ago

I'm having the same problem. Logind session has Type=tty and swayidle cannot set IdleHint. I have XDG_SESSION_TYPE=wayland.

~robertmueller2 5 days ago*

I'm observing the same issue on a Debian system with greetd and tuigreet. Setting XDG_SESSION_TYPE=wayland in a wrapper script is not sufficient on my machine. The "Failed to send SetIdleHint signal: Idle hint control is not supported on non-graphical sessions." messages are logged, too.

After a bit of research, it appears to me that pam_systemd.so is where XDG_SESSION_TYPE is evaluated. Other LMs than greetd might do that as well, I've really not checked that, but Sway itself does not, I think. The pam module has a debug parameter. So after configuring

/etc/pam.d/common-session
session optional pam_systemd.so debug=true

I get messages like this:
Aug 05 19:11:02 HOSTNAME greetd[224305]: pam_systemd(login:session): Asking logind to create session: uid=1000 pid=224305 service=login type=tty class=user desktop= seat=seat0 vtnr=7 tty=tty7 display= remote=no remote_user= remote_host=

I've tried using
command = "env XDG_SESSION_TYPE=wayland tuigreet --remember --remember-user-session --issue --sessions /usr/local/share/wayland-sessions:/usr/local/share/xsessions:/usr/share/wayland-sessions:/usr/share/xsessions"
in config.toml, but that doesn't work. It's not a huge surprise, because my user might not like greeter's env variables. ;)

Configuring this in /etc/pam.d/common-session, just for testing, works for me:
session optional pam_systemd.so debug=true type=wayland

Aug 05 19:36:28 HOSTNAME greetd[254943]: pam_systemd(login:session): Asking logind to create session: uid=1000 pid=254943 service=login type=wayland class=user desktop= seat=seat0 vtnr=7 tty=tty7 display= remote=no remote_user= remote_host=

But that's not ideal, of course, if I want to login on tty, or login to the machine via ssh.

I'm not sure if there is any other pam hook that could be used. I should think for those distros where it does work, there's another invocation of pam_systemd.so. But when common-session is the only place that applies it, setting the environment variable in the wrapper script or .desktop file is too late, because at that point the session is already started and the module has done its magic.

Register here or Log in to comment, or comment via email.