at 17.09-beta 5.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4with builtins; 5 6let 7 8 cfg = config.services.compton; 9 10 configFile = pkgs.writeText "compton.conf" 11 (optionalString cfg.fade '' 12 # fading 13 fading = true; 14 fade-delta = ${toString cfg.fadeDelta}; 15 fade-in-step = ${elemAt cfg.fadeSteps 0}; 16 fade-out-step = ${elemAt cfg.fadeSteps 1}; 17 fade-exclude = ${toJSON cfg.fadeExclude}; 18 '' + 19 optionalString cfg.shadow '' 20 21 # shadows 22 shadow = true; 23 shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)}; 24 shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; 25 shadow-opacity = ${cfg.shadowOpacity}; 26 shadow-exclude = ${toJSON cfg.shadowExclude}; 27 '' + '' 28 29 # opacity 30 active-opacity = ${cfg.activeOpacity}; 31 inactive-opacity = ${cfg.inactiveOpacity}; 32 menu-opacity = ${cfg.menuOpacity}; 33 34 # other options 35 backend = ${toJSON cfg.backend}; 36 vsync = ${toJSON cfg.vSync}; 37 refresh-rate = ${toString cfg.refreshRate}; 38 '' + cfg.extraOptions); 39 40in { 41 42 options.services.compton = { 43 enable = mkOption { 44 type = types.bool; 45 default = false; 46 description = '' 47 Whether of not to enable Compton as the X.org composite manager. 48 ''; 49 }; 50 51 fade = mkOption { 52 type = types.bool; 53 default = false; 54 description = '' 55 Fade windows in and out. 56 ''; 57 }; 58 59 fadeDelta = mkOption { 60 type = types.int; 61 default = 10; 62 example = 5; 63 description = '' 64 Time between fade animation step (in ms). 65 ''; 66 }; 67 68 fadeSteps = mkOption { 69 type = types.listOf types.str; 70 default = [ "0.028" "0.03" ]; 71 example = [ "0.04" "0.04" ]; 72 description = '' 73 Opacity change between fade steps (in and out). 74 ''; 75 }; 76 77 fadeExclude = mkOption { 78 type = types.listOf types.str; 79 default = []; 80 example = [ 81 "window_type *= 'menu'" 82 "name ~= 'Firefox$'" 83 "focused = 1" 84 ]; 85 description = '' 86 List of conditions of windows that should not be faded. 87 See <literal>compton(1)</literal> man page for more examples. 88 ''; 89 }; 90 91 shadow = mkOption { 92 type = types.bool; 93 default = false; 94 description = '' 95 Draw window shadows. 96 ''; 97 }; 98 99 shadowOffsets = mkOption { 100 type = types.listOf types.int; 101 default = [ (-15) (-15) ]; 102 example = [ (-10) (-15) ]; 103 description = '' 104 Left and right offset for shadows (in pixels). 105 ''; 106 }; 107 108 shadowOpacity = mkOption { 109 type = types.str; 110 default = "0.75"; 111 example = "0.8"; 112 description = '' 113 Window shadows opacity (number in range 0 - 1). 114 ''; 115 }; 116 117 shadowExclude = mkOption { 118 type = types.listOf types.str; 119 default = []; 120 example = [ 121 "window_type *= 'menu'" 122 "name ~= 'Firefox$'" 123 "focused = 1" 124 ]; 125 description = '' 126 List of conditions of windows that should have no shadow. 127 See <literal>compton(1)</literal> man page for more examples. 128 ''; 129 }; 130 131 activeOpacity = mkOption { 132 type = types.str; 133 default = "1.0"; 134 example = "0.8"; 135 description = '' 136 Opacity of active windows. 137 ''; 138 }; 139 140 inactiveOpacity = mkOption { 141 type = types.str; 142 default = "1.0"; 143 example = "0.8"; 144 description = '' 145 Opacity of inactive windows. 146 ''; 147 }; 148 149 menuOpacity = mkOption { 150 type = types.str; 151 default = "1.0"; 152 example = "0.8"; 153 description = '' 154 Opacity of dropdown and popup menu. 155 ''; 156 }; 157 158 backend = mkOption { 159 type = types.str; 160 default = "glx"; 161 description = '' 162 Backend to use: <literal>glx</literal> or <literal>xrender</literal>. 163 ''; 164 }; 165 166 vSync = mkOption { 167 type = types.str; 168 default = "none"; 169 example = "opengl-swc"; 170 description = '' 171 Enable vertical synchronization using the specified method. 172 See <literal>compton(1)</literal> man page available methods. 173 ''; 174 }; 175 176 refreshRate = mkOption { 177 type = types.int; 178 default = 0; 179 example = 60; 180 description = '' 181 Screen refresh rate (0 = automatically detect). 182 ''; 183 }; 184 185 package = mkOption { 186 type = types.package; 187 default = pkgs.compton; 188 defaultText = "pkgs.compton"; 189 example = literalExample "pkgs.compton"; 190 description = '' 191 Compton derivation to use. 192 ''; 193 }; 194 195 extraOptions = mkOption { 196 type = types.str; 197 default = ""; 198 example = '' 199 unredir-if-possible = true; 200 dbe = true; 201 ''; 202 description = '' 203 Additional Compton configuration. 204 ''; 205 }; 206 }; 207 208 config = mkIf cfg.enable { 209 systemd.user.services.compton = { 210 description = "Compton composite manager"; 211 wantedBy = [ "graphical-session.target" ]; 212 partOf = [ "graphical-session.target" ]; 213 serviceConfig = { 214 ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; 215 RestartSec = 3; 216 Restart = "always"; 217 }; 218 }; 219 220 environment.systemPackages = [ cfg.package ]; 221 }; 222 223}