[systemd-devel] Q: What is the correct way to use `xdg-desktop-autostart.target` with window managers?

Andrei Borzenkov arvidjaar at gmail.com
Fri Jul 19 18:18:20 UTC 2024


On 19.07.2024 16:52, WieeRd wrote:
> I'm trying to use systemd as a XDG Autostart manager for WMs that does not
> provide builtin support for autostart entries. At first, I simply tried to
> `systemctl --user start` the target inside the window manager. However, it
> quickly turned out that the target cannot and not meant to be manually
> started and instead should be specified as a `Wants=` dependency.
> 
> But how exactly?
> 
> 1. Which unit should be linked to the autostart target as `Wants=`
> dependency?

It is entirely up to your desktop environment. Only DE knows where 
autostart fits in its startup sequence.

> Should the user /  WM author create / provide another user unit just so
> that it can pull in the autostart target?
> 

Assumption is that your desktop environment is using systemd user 
instance to manage its services already. In which case you already have 
at least one systemd unit which is launched when you start this desktop 
environment.

> 2. Looking at the source code, it seems that `OnlyShowIn=` detection relies
> on the $XDG_CURRENT_DESKTOP environment.
> Whose responsibility is it to set this variable? Display manager? Window
> manager? Or by the user?
>

As the name likely comes from the session desktop file, I'd say display 
manager. GDM sets it for sure.

> The man pages of `systemd.special` and `systemd-xdg-autostart-generator`
> were the only documentations I could find about this feature, and I'm still
> not sure what I'm supposed to do.

It was never considered as a standalone feature, rather as a helper to 
migrate autostarted processes to systemd units for better manageability. 
But e.g. KDE is explicitly using transient units for this purpose and so 
does not use or need x-d-a.t at all.


More information about the systemd-devel mailing list