at master 3.5 kB view raw
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 ../../desktop-managers/plasma6.nix 30 ./lumina.nix 31 ./lxqt.nix 32 ./enlightenment.nix 33 ./retroarch.nix 34 ./kodi.nix 35 ./mate.nix 36 ../../desktop-managers/pantheon.nix 37 ./surf-display.nix 38 ./cde.nix 39 ./cinnamon.nix 40 ./budgie.nix 41 ../../desktop-managers/lomiri.nix 42 ../../desktop-managers/cosmic.nix 43 ../../desktop-managers/gnome.nix 44 ]; 45 46 options = { 47 48 services.xserver.desktopManager = { 49 50 wallpaper = { 51 mode = mkOption { 52 type = types.enum [ 53 "center" 54 "fill" 55 "max" 56 "scale" 57 "tile" 58 ]; 59 default = "scale"; 60 example = "fill"; 61 description = '' 62 The file {file}`~/.background-image` is used as a background image. 63 This option specifies the placement of this image onto your desktop. 64 65 Possible values: 66 `center`: Center the image on the background. If it is too small, it will be surrounded by a black border. 67 `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. 68 `max`: Like `fill`, but scale the image to the maximum size that fits the screen with black borders on one side. 69 `scale`: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either. 70 `tile`: Tile (repeat) the image in case it is too small for the screen. 71 ''; 72 }; 73 74 combineScreens = mkOption { 75 type = types.bool; 76 default = false; 77 description = '' 78 When set to `true` the wallpaper will stretch across all screens. 79 When set to `false` the wallpaper is duplicated to all screens. 80 ''; 81 }; 82 }; 83 84 session = mkOption { 85 internal = true; 86 default = [ ]; 87 example = lib.singleton { 88 name = "kde"; 89 bgSupport = true; 90 start = "..."; 91 }; 92 description = '' 93 Internal option used to add some common line to desktop manager 94 scripts before forwarding the value to the 95 `displayManager`. 96 ''; 97 apply = map ( 98 d: 99 d 100 // { 101 manage = "desktop"; 102 start = 103 d.start 104 # literal newline to ensure d.start's last line is not appended to 105 + lib.optionalString (needBGCond d) '' 106 107 if [ -e $HOME/.background-image ]; then 108 ${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${lib.optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image 109 fi 110 ''; 111 } 112 ); 113 }; 114 115 }; 116 117 }; 118 119 config.services.xserver.displayManager.session = cfg.session; 120}