1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 inherit (lib) mkOption types;
10
11 xcfg = config.services.xserver;
12 cfg = xcfg.desktopManager;
13
14 # If desktop manager `d' isn't capable of setting a background and
15 # the xserver is enabled, `feh' or `xsetroot' are used as a fallback.
16 needBGCond = d: !(d ? bgSupport && d.bgSupport) && xcfg.enable;
17
18in
19
20{
21 # Note: the order in which desktop manager modules are imported here
22 # determines the default: later modules (if enabled) are preferred.
23 # E.g., if Plasma 5 is enabled, it supersedes xterm.
24 imports = [
25 ./none.nix
26 ./xterm.nix
27 ./phosh.nix
28 ./xfce.nix
29 ./plasma5.nix
30 ../../desktop-managers/plasma6.nix
31 ./lumina.nix
32 ./lxqt.nix
33 ./enlightenment.nix
34 ./gnome.nix
35 ./retroarch.nix
36 ./kodi.nix
37 ./mate.nix
38 ./pantheon.nix
39 ./surf-display.nix
40 ./cde.nix
41 ./cinnamon.nix
42 ./budgie.nix
43 ./deepin.nix
44 ../../desktop-managers/lomiri.nix
45 ../../desktop-managers/cosmic.nix
46 ];
47
48 options = {
49
50 services.xserver.desktopManager = {
51
52 wallpaper = {
53 mode = mkOption {
54 type = types.enum [
55 "center"
56 "fill"
57 "max"
58 "scale"
59 "tile"
60 ];
61 default = "scale";
62 example = "fill";
63 description = ''
64 The file {file}`~/.background-image` is used as a background image.
65 This option specifies the placement of this image onto your desktop.
66
67 Possible values:
68 `center`: Center the image on the background. If it is too small, it will be surrounded by a black border.
69 `fill`: Like `scale`, but preserves aspect ratio by zooming the image until it fits. Either a horizontal or a vertical part of the image will be cut off.
70 `max`: Like `fill`, but scale the image to the maximum size that fits the screen with black borders on one side.
71 `scale`: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either.
72 `tile`: Tile (repeat) the image in case it is too small for the screen.
73 '';
74 };
75
76 combineScreens = mkOption {
77 type = types.bool;
78 default = false;
79 description = ''
80 When set to `true` the wallpaper will stretch across all screens.
81 When set to `false` the wallpaper is duplicated to all screens.
82 '';
83 };
84 };
85
86 session = mkOption {
87 internal = true;
88 default = [ ];
89 example = lib.singleton {
90 name = "kde";
91 bgSupport = true;
92 start = "...";
93 };
94 description = ''
95 Internal option used to add some common line to desktop manager
96 scripts before forwarding the value to the
97 `displayManager`.
98 '';
99 apply = map (
100 d:
101 d
102 // {
103 manage = "desktop";
104 start =
105 d.start
106 # literal newline to ensure d.start's last line is not appended to
107 + lib.optionalString (needBGCond d) ''
108
109 if [ -e $HOME/.background-image ]; then
110 ${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${lib.optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image
111 fi
112 '';
113 }
114 );
115 };
116
117 };
118
119 };
120
121 config.services.xserver.displayManager.session = cfg.session;
122}