1{ config, lib, pkgs, ... }:
2with lib;
3let
4 runXdgAutostart = config.services.xserver.desktopManager.runXdgAutostartIfNone;
5in
6{
7 options = {
8 services.xserver.desktopManager.runXdgAutostartIfNone = mkOption {
9 type = types.bool;
10 default = false;
11 description = lib.mdDoc ''
12 Whether to run XDG autostart files for sessions without a desktop manager
13 (with only a window manager), these sessions usually don't handle XDG
14 autostart files by default.
15
16 Some services like {option}`i18n.inputMethod` and
17 {option}`service.earlyoom` use XDG autostart files to start.
18 If this option is not set to `true` and you are using
19 a window manager without a desktop manager, you need to manually start
20 them or running `dex` somewhere.
21 '';
22 };
23 };
24
25 config = mkMerge [
26 {
27 services.xserver.desktopManager.session = [
28 {
29 name = "none";
30 start = optionalString runXdgAutostart ''
31 /run/current-system/systemd/bin/systemctl --user start xdg-autostart-if-no-desktop-manager.target
32 '';
33 }
34 ];
35 }
36 (mkIf runXdgAutostart {
37 systemd.user.targets.xdg-autostart-if-no-desktop-manager = {
38 description = "Run XDG autostart files";
39 # From `plasma-workspace`, `share/systemd/user/plasma-workspace@.target`.
40 requires = [ "xdg-desktop-autostart.target" "graphical-session.target" ];
41 before = [ "xdg-desktop-autostart.target" "graphical-session.target" ];
42 bindsTo = [ "graphical-session.target" ];
43 };
44 })
45 ];
46}