at 18.09-beta 4.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 xcfg = config.services.xserver; 8 cfg = xcfg.desktopManager; 9 10 # If desktop manager `d' isn't capable of setting a background and 11 # the xserver is enabled, `feh' or `xsetroot' are used as a fallback. 12 needBGCond = d: ! (d ? bgSupport && d.bgSupport) && xcfg.enable; 13 14in 15 16{ 17 # Note: the order in which desktop manager modules are imported here 18 # determines the default: later modules (if enabled) are preferred. 19 # E.g., if Plasma 5 is enabled, it supersedes xterm. 20 imports = [ 21 ./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix 22 ./lxqt.nix ./enlightenment.nix ./gnome3.nix ./kodi.nix ./maxx.nix 23 ./mate.nix 24 ]; 25 26 options = { 27 28 services.xserver.desktopManager = { 29 30 wallpaper = { 31 mode = mkOption { 32 type = types.enum [ "center" "fill" "max" "scale" "tile" ]; 33 default = "scale"; 34 example = "fill"; 35 description = '' 36 The file <filename>~/.background-image</filename> is used as a background image. 37 This option specifies the placement of this image onto your desktop. 38 39 Possible values: 40 <literal>center</literal>: Center the image on the background. If it is too small, it will be surrounded by a black border. 41 <literal>fill</literal>: Like <literal>scale</literal>, 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. 42 <literal>max</literal>: Like <literal>fill</literal>, but scale the image to the maximum size that fits the screen with black borders on one side. 43 <literal>scale</literal>: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either. 44 <literal>tile</literal>: Tile (repeat) the image in case it is too small for the screen. 45 ''; 46 }; 47 48 combineScreens = mkOption { 49 type = types.bool; 50 default = false; 51 description = '' 52 When set to <literal>true</literal> the wallpaper will stretch across all screens. 53 When set to <literal>false</literal> the wallpaper is duplicated to all screens. 54 ''; 55 }; 56 }; 57 58 session = mkOption { 59 internal = true; 60 default = []; 61 example = singleton 62 { name = "kde"; 63 bgSupport = true; 64 start = "..."; 65 }; 66 description = '' 67 Internal option used to add some common line to desktop manager 68 scripts before forwarding the value to the 69 <varname>displayManager</varname>. 70 ''; 71 apply = list: { 72 list = map (d: d // { 73 manage = "desktop"; 74 start = d.start 75 + optionalString (needBGCond d) '' 76 if [ -e $HOME/.background-image ]; then 77 ${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image 78 else 79 # Use a solid black background as fallback 80 ${pkgs.xorg.xsetroot}/bin/xsetroot -solid black 81 fi 82 ''; 83 }) list; 84 needBGPackages = [] != filter needBGCond list; 85 }; 86 }; 87 88 default = mkOption { 89 type = types.str; 90 default = ""; 91 example = "none"; 92 description = "Default desktop manager loaded if none have been chosen."; 93 apply = defaultDM: 94 if defaultDM == "" && cfg.session.list != [] then 95 (head cfg.session.list).name 96 else if any (w: w.name == defaultDM) cfg.session.list then 97 defaultDM 98 else 99 builtins.trace '' 100 Default desktop manager (${defaultDM}) not found at evaluation time. 101 These are the known valid session names: 102 ${concatMapStringsSep "\n " (w: "services.xserver.desktopManager.default = \"${w.name}\";") cfg.session.list} 103 It's also possible the default can be found in one of these packages: 104 ${concatMapStringsSep "\n " (p: p.name) config.services.xserver.displayManager.extraSessionFilePackages} 105 '' defaultDM; 106 }; 107 108 }; 109 110 }; 111 112 config.services.xserver.displayManager.session = cfg.session.list; 113}