blob: 981d1cadee9639f6c9278d0016841d0ba256c77d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# Loads X resources into each X session, before the session's other
# services start.
{ config, lib, pkgs, ... }: let
cfg = config.hrm.xresources;
files =
pkgs.linkFarm "xresources"
(lib.mapAttrs
(display: resources:
pkgs.writeText "xresources-${display}"
(lib.concatStrings
(lib.mapAttrsToList
(name: value: "${name}: ${value}\n")
resources)))
({ "*" = {}; } // cfg));
in {
options.hrm.xresources = lib.mkOption {
default = {};
type = lib.types.attrsOf (lib.types.attrsOf lib.types.str);
example = {
"*"."Xcursor.size" = "64";
"8"."XTerm*background" = "#1e171e";
};
description = ''
X resources, by display number. Those under "*" are for every
display, and a display's own override them.
'';
};
config = lib.mkIf config.hrm.xsession.enable {
hrm.xsession.services = [ "xresources" ];
systemd.user.services."xresources@".serviceConfig = {
ExecStart = pkgs.writeDash "xresources-load" ''
set -efu
LC_ALL=C ${pkgs.xrdb}/bin/xrdb -load ${files}/'*'
f=${files}/''${DISPLAY#:}
if test -e "$f"; then
LC_ALL=C ${pkgs.xrdb}/bin/xrdb -override "$f"
fi
'';
RemainAfterExit = true;
Type = "oneshot";
};
};
}
|