aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/eww/default.nix
blob: fad0cc4c409a992f5b5773f10ca0b3b6ee692877 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  config,
  lib,
  ...
}:
{
  imports = [
    ./bar.nix
  ];

  options.desktop.eww = {
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.programs.eww.package;
      description = "The eww package to use.";
    };
  };

  config = {
    programs.eww = {
      enable = true;
      systemd.enable = true;
      scssConfig =
        let
          baseSize = config.fonts.size;
        in
        builtins.readFile (
          config.scheme {
            template =
              builtins.replaceStrings
                [
                  "@@font-family@@"
                  "@@font-size@@"
                  "@@font-size-icon@@"
                  "@@font-size-label@@"
                  "@@font-size-small@@"
                  "@@font-size-idx@@"
                ]
                [
                  config.fonts.normal
                  (toString baseSize)
                  (toString (baseSize + 6))
                  (toString (baseSize - 2))
                  (toString (baseSize - 6))
                  (toString (baseSize - 4))
                ]
                (builtins.readFile ./eww.mustache.scss);
          }
        );
    };

    systemd.user.services.eww-bar = {
      Unit = {
        Description = "Open Eww Bar";
        After = [ "eww.service" ];
        Requires = [ "eww.service" ];
      };
      Service = {
        Type = "oneshot";
        RemainAfterExit = true;
        ExecStart = "${lib.getExe config.desktop.eww.package} open bar";
        ExecStop = "${lib.getExe config.desktop.eww.package} close bar";
      };
      Install = {
        WantedBy = [ config.programs.eww.systemd.target ];
      };
    };
  };
}