eccb90a2d9
* compton-git: 5.1-rc2 -> 6.2 vsync is now a boolean option, see: https://github.com/yshui/compton/pull/130 menu-opacity is deprecated and there's a warning that says: Please use the wintype option `opacity` of `popup_menu` and `dropdown_menu` instead. * nixos/compton: Keep vSync option backwards compatible The new upstream option tries to make the best choice for the user. Therefore the behaviour should stay the same with this backwards compatibility patch. * compton-git: Remove DRM option It's deprecated and shouldn't be used. https://github.com/yshui/compton/pull/130/files#r285505456 * compton-git: Remove new_backends option Was removed in "Let old/new backends co-exist" b0c5db9f5aa500dc3568cc6fe68493df98794d4d * compton: 0.1_beta2.5 -> 6.2 Drop the legacy, unmaintained version and use the fork for real.
269 lines
6.9 KiB
Nix
269 lines
6.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
with builtins;
|
|
|
|
let
|
|
|
|
cfg = config.services.compton;
|
|
|
|
floatBetween = a: b: with lib; with types;
|
|
addCheck str (x: versionAtLeast x a && versionOlder x b);
|
|
|
|
pairOf = x: with types; addCheck (listOf x) (y: lib.length y == 2);
|
|
|
|
opacityRules = optionalString (length cfg.opacityRules != 0)
|
|
(concatMapStringsSep ",\n" (rule: ''"${rule}"'') cfg.opacityRules);
|
|
|
|
configFile = pkgs.writeText "compton.conf"
|
|
(optionalString cfg.fade ''
|
|
# fading
|
|
fading = true;
|
|
fade-delta = ${toString cfg.fadeDelta};
|
|
fade-in-step = ${elemAt cfg.fadeSteps 0};
|
|
fade-out-step = ${elemAt cfg.fadeSteps 1};
|
|
fade-exclude = ${toJSON cfg.fadeExclude};
|
|
'' +
|
|
optionalString cfg.shadow ''
|
|
|
|
# shadows
|
|
shadow = true;
|
|
shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)};
|
|
shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)};
|
|
shadow-opacity = ${cfg.shadowOpacity};
|
|
shadow-exclude = ${toJSON cfg.shadowExclude};
|
|
'' + ''
|
|
|
|
# opacity
|
|
active-opacity = ${cfg.activeOpacity};
|
|
inactive-opacity = ${cfg.inactiveOpacity};
|
|
|
|
wintypes:
|
|
{
|
|
popup_menu = { opacity = ${cfg.menuOpacity}; }
|
|
dropdown_menu = { opacity = ${cfg.menuOpacity}; }
|
|
};
|
|
|
|
opacity-rule = [
|
|
${opacityRules}
|
|
];
|
|
|
|
# other options
|
|
backend = ${toJSON cfg.backend};
|
|
vsync = ${lib.boolToString cfg.vSync};
|
|
refresh-rate = ${toString cfg.refreshRate};
|
|
'' + cfg.extraOptions);
|
|
|
|
in {
|
|
|
|
options.services.compton = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether of not to enable Compton as the X.org composite manager.
|
|
'';
|
|
};
|
|
|
|
fade = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Fade windows in and out.
|
|
'';
|
|
};
|
|
|
|
fadeDelta = mkOption {
|
|
type = types.addCheck types.int (x: x > 0);
|
|
default = 10;
|
|
example = 5;
|
|
description = ''
|
|
Time between fade animation step (in ms).
|
|
'';
|
|
};
|
|
|
|
fadeSteps = mkOption {
|
|
type = pairOf (floatBetween "0.01" "1.01");
|
|
default = [ "0.028" "0.03" ];
|
|
example = [ "0.04" "0.04" ];
|
|
description = ''
|
|
Opacity change between fade steps (in and out).
|
|
(numbers in range 0.01 - 1.0)
|
|
'';
|
|
};
|
|
|
|
fadeExclude = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [
|
|
"window_type *= 'menu'"
|
|
"name ~= 'Firefox$'"
|
|
"focused = 1"
|
|
];
|
|
description = ''
|
|
List of conditions of windows that should not be faded.
|
|
See <literal>compton(1)</literal> man page for more examples.
|
|
'';
|
|
};
|
|
|
|
shadow = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Draw window shadows.
|
|
'';
|
|
};
|
|
|
|
shadowOffsets = mkOption {
|
|
type = pairOf types.int;
|
|
default = [ (-15) (-15) ];
|
|
example = [ (-10) (-15) ];
|
|
description = ''
|
|
Left and right offset for shadows (in pixels).
|
|
'';
|
|
};
|
|
|
|
shadowOpacity = mkOption {
|
|
type = floatBetween "0.0" "1.01";
|
|
default = "0.75";
|
|
example = "0.8";
|
|
description = ''
|
|
Window shadows opacity (number in range 0.0 - 1.0).
|
|
'';
|
|
};
|
|
|
|
shadowExclude = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [
|
|
"window_type *= 'menu'"
|
|
"name ~= 'Firefox$'"
|
|
"focused = 1"
|
|
];
|
|
description = ''
|
|
List of conditions of windows that should have no shadow.
|
|
See <literal>compton(1)</literal> man page for more examples.
|
|
'';
|
|
};
|
|
|
|
activeOpacity = mkOption {
|
|
type = floatBetween "0.0" "1.01";
|
|
default = "1.0";
|
|
example = "0.8";
|
|
description = ''
|
|
Opacity of active windows (number in range 0.0 - 1.0).
|
|
'';
|
|
};
|
|
|
|
inactiveOpacity = mkOption {
|
|
type = floatBetween "0.1" "1.01";
|
|
default = "1.0";
|
|
example = "0.8";
|
|
description = ''
|
|
Opacity of inactive windows (number in range 0.1 - 1.0).
|
|
'';
|
|
};
|
|
|
|
menuOpacity = mkOption {
|
|
type = floatBetween "0.0" "1.01";
|
|
default = "1.0";
|
|
example = "0.8";
|
|
description = ''
|
|
Opacity of dropdown and popup menu (number in range 0.0 - 1.0).
|
|
'';
|
|
};
|
|
|
|
opacityRules = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [];
|
|
example = [
|
|
"95:class_g = 'URxvt' && !_NET_WM_STATE@:32a"
|
|
"0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
|
|
];
|
|
description = ''
|
|
Rules that control the opacity of windows, in format PERCENT:PATTERN.
|
|
'';
|
|
};
|
|
|
|
backend = mkOption {
|
|
type = types.enum [ "glx" "xrender" "xr_glx_hybrid" ];
|
|
default = "xrender";
|
|
description = ''
|
|
Backend to use: <literal>glx</literal>, <literal>xrender</literal> or <literal>xr_glx_hybrid</literal>.
|
|
'';
|
|
};
|
|
|
|
vSync = mkOption {
|
|
type = with types; either bool
|
|
(enum [ "none" "drm" "opengl" "opengl-oml" "opengl-swc" "opengl-mswc" ]);
|
|
default = false;
|
|
apply = x:
|
|
let
|
|
res = x != "none";
|
|
msg = "The type of services.compton.vSync has changed to bool:"
|
|
+ " interpreting ${x} as ${lib.boolToString res}";
|
|
in
|
|
if isBool x then x
|
|
else warn msg res;
|
|
|
|
description = ''
|
|
Enable vertical synchronization. Chooses the best method
|
|
(drm, opengl, opengl-oml, opengl-swc, opengl-mswc) automatically.
|
|
The bool value should be used, the others are just for backwards compatibility.
|
|
'';
|
|
};
|
|
|
|
refreshRate = mkOption {
|
|
type = types.addCheck types.int (x: x >= 0);
|
|
default = 0;
|
|
example = 60;
|
|
description = ''
|
|
Screen refresh rate (0 = automatically detect).
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.compton;
|
|
defaultText = "pkgs.compton";
|
|
example = literalExample "pkgs.compton";
|
|
description = ''
|
|
Compton derivation to use.
|
|
'';
|
|
};
|
|
|
|
extraOptions = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
example = ''
|
|
unredir-if-possible = true;
|
|
dbe = true;
|
|
'';
|
|
description = ''
|
|
Additional Compton configuration.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.user.services.compton = {
|
|
description = "Compton composite manager";
|
|
wantedBy = [ "graphical-session.target" ];
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
# Temporarily fixes corrupt colours with Mesa 18
|
|
environment = mkIf (cfg.backend == "glx") {
|
|
allow_rgb10_configs = "false";
|
|
};
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/compton --config ${configFile}";
|
|
RestartSec = 3;
|
|
Restart = "always";
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
};
|
|
|
|
}
|