#1050981 xmonad: please set XDG_CURRENT_DESKTOP and use it to configure xdg-desktop-portal

Package:
xmonad
Source:
xmonad
Description:
Lightweight X11 window manager written in Haskell
Submitter:
Simon McVittie
Date:
2026-01-10 10:58:10 UTC
Severity:
normal
#1050981#5
Date:
2023-09-01 00:50:00 UTC
From:
To:
xdg-desktop-portal 1.17.x introduces a new way to select which portals will
be used for which desktop environments, modelled on mimeapps.list:

- each desktop environment should provide a file like
  /usr/share/xdg-desktop-portal/xmonad-portals.conf

- the filename is ${DESKTOP}-portals.conf where ${DESKTOP} is the desktop
  environment's entry in $XDG_CURRENT_DESKTOP (the same as the DesktopNames
  from /usr/share/{x,wayland-}sessions/*.desktop), folded to lower case

- sysadmins and users can override this via files named portals.conf or
  ${DESKTOP}-portals.conf in various locations like /etc/xdg-desktop-portal
  and ~/.config/xdg-desktop-portal

But as far as I can tell, XMonad doesn't set XDG_CURRENT_DESKTOP, so for
the purposes of this mechanism, it's not programmatically distinguishable
from any other desktop environment or window manager.

XDG_CURRENT_DESKTOP is also used in pre-existing freedesktop.org standards
like the OnlyShowIn/NotShowIn fields for .desktop files, and the ability to
provide a desktop-environment-specific mimeapps.list. Setting
XDG_CURRENT_DESKTOP would allow XMonad to participate in those
specifications.

The "GNOME Flashback (Xmonad)" session *does* set XDG_CURRENT_DESKTOP, but
to a value that is indistinguishable from the ordinary GNOME Flashback
session with the metacity window manager, and I don't know whether that's
the most appropriate thing for the purposes of desktop-specific
configuration or not.

To reproduce
============

* Start from a basic non-GUI virtual machine (I used autopkgtest-build-qemu)
* Ensure that a user account exists
* apt install lightdm xorg xmonad
* reboot
* Log in as the user account, selecting "XMonad" from the menu of
  possible X11 sessions
* In a ssh session as the same user, run:
  systemctl --user show-environment
* apt install gnome-session-flashback
* Repeat for the "GNOME Flashback (Xmonad)" session

(I couldn't work out how to open a shell in an otherwise unconfigured
XMonad session, but in any case it's the systemd activation environment
that matters here, more than `env`, because xdg-desktop-portal will
typically be run as a systemd user service.)

Expected result
===============

XDG_CURRENT_DESKTOP should be set to a colon-separated sequence of
desktop environment names, most specific first. XMonad seems to be its
own thing rather than being based on another desktop environment or
window manager, so

    XDG_CURRENT_DESKTOP=XMonad

would seem appropriate.

This would allow the XMonad session to have its own
desktop-environment-specific mimeapps.list or portals.conf(5), for
example /usr/share/xdg-desktop-portal/xmonad-portals.conf.

For XMonad's GNOME Flashback variant, I don't know whether
XDG_CURRENT_DESKTOP should be set to GNOME-Flashback:GNOME (exactly
the same as GNOME Flashback with metacity), or whether it would be better
to set it to something like XMonad-GNOME-Flashback:GNOME-Flashback:GNOME
so that XMonad's GNOME Flashback variant can have its own portal
configuration, mimeapps.list, OnlyShowIn/NotShowIn, etc. if it wants to
(in principle someone could develop a portal backend similar to
xdg-desktop-portal-gtk that works better with tiling window managers,
although I'm not aware of such a thing having been written).

Actual result
=============

In the XMonad session, XDG_CURRENT_DESKTOP is unset.

This means that xdg-desktop-portal configuration can only be done via a
non-desktop-specific portals.conf, but that's not really something that a
non-opinionated distribution like Debian can usefully ship in a centralized
way, so each user of XMonad who wants a working xdg-desktop-portal will
have to configure it themselves.

At the moment, this is mitigated by xdg-desktop-portal (>= 1.17) having
been patched to fall back to xdg-desktop-portal-gtk as a last-resort
desktop-environment-specific backend, but hard-coding that implementation
isn't really something we should be doing centrally (and the idea was
rejected upstream), so I intend to remove that patch before trixie
is released.

For XMonad's GNOME Flashback variant, XDG_CURRENT_DESKTOP is currently set
to GNOME-Flashback:GNOME (exactly the same as GNOME Flashback with metacity),
so it will always use the same portal configuration, etc. as
gnome-session-flashback (see #1050799).

Suggested fix
=============

Add a sequence of semicolon-separated desktop environment names to
/usr/share/xsessions/xmonad.desktop, most likely just "XMonad":

DesktopNames=XMonad;

(For example, icewm and windowmaker use "ICEWM" and "WindowMaker" in
their equivalent xsessions file.)

And then create a /usr/share/xdg-desktop-portal/xmonad-portals.conf
with whatever portal backends are desired for an XMonad session,
for example perhaps this:

[preferred]
default=gtk;

Please see portals.conf(5) or its source code
https://github.com/flatpak/xdg-desktop-portal/blob/main/doc/portals-conf.rst
for full details.

For XMonad's GNOME Flashback variant, there are two options. If it's
intentional that it is configured the same as the metacity-based GNOME
Flashback session in all respects (portals, mimeapps.list,
OnlyShowIn/NotShowIn, etc.) then it's OK to leave it as-is, with
"DesktopNames=GNOME-Flashback;GNOME;". Or, if it might be desirable to give
it its own desktop-specific configuration, then it should have something
like "DesktopNames=XMonad-GNOME-Flashback;GNOME-Flashback;GNOME;".

Thanks,
    smcv

#1050981#10
Date:
2026-01-10 10:10:29 UTC
From:
To:
Es gibt eine Familienspende in Höhe von 1.850.000,00 USD von Cheng Charlie
Saephan. Bitte antworten Sie für weitere Informationen. Denken Sie daran,
Ihrer Familie und den Bedürftigen in Ihrer Umgebung Gutes zu tun.

Dies ist bereits der zweite Versuch, Sie zu erreichen. Bitte antworten Sie
für weitere Details.