Question about the XDG_SESSION_TYPE environmental variable

Michal Srb msrb at
Fri Jul 20 07:19:14 UTC 2018


Is there some documentation for the XDG_SESSION_TYPE environmental variable? 
So far the only think I managed to find is the pam_systemd manual page.

I have observed that multiple display managers (at least GDM, SDDM and 
LightDM) set this variable and some applications use it to determine the type 
of current session. Also the Qt toolkit uses it to decide if it should 
prioritize the X11 or Wayland backend.

IMHO that usage makes sense, because in some situations both X11 and Wayland 
displays are available and the toolkit needs to know which one is preferred. 
If it would unconditionally prefer X11, it may end up using Xwayland when 
started from Wayland session. If it would unconditionally prefer Wayland, it 
may end up connecting to a completely unrelated "wayland-0" display when 
started from X11 session.

GTK currently unconditionally prefer Wayland and I have hit a bug when GTK 
applications started from X11 session start in unrelated Wayland session. So I 
tried to advocate the use of this variable for backend selection in GTK:

However the authors are reluctant to use the XDG_SESSION_TYPE variable without 
seeing further documentation or some discussion on where it came from. Does 
anything like that exist? If not, is there chance the variable will be 

Best regards,
Michal Srb

More information about the xdg mailing list