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