aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/darkman/default.nix
blob: 9dc7ef93c024c900eaba867f5114b43c15e583db (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
# Darkman - Automatic dark/light mode switching based on time of day
{
  config,
  lib,
  pkgs,
  ...
}:
{
  options.desktop.darkman = {
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.services.darkman.package;
      description = "The darkman package to use.";
    };
  };

  config = lib.mkIf config.desktop.enable {
    services.darkman = {
      enable = true;
      settings = {
        portal = true;
        lat = 0;
        lng = 0;
      };
    };

    xdg.portal = {
      enable = true;
      extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
      config.common = {
        default = [ "hyprland" ];
        "org.freedesktop.impl.portal.Settings" = "darkman";
      };
    };

    # Always dark by default
    systemd.user.services.darkman-set-theme = {
      Unit = {
        Description = "Set Darkman to dark on graphical session startup";
        PartOf = [ "graphical-session.target" ];
        After = [ "graphical-session.target" ];
      };

      Service = {
        Type = "oneshot";
        ExecStart = "${lib.getExe config.desktop.darkman.package} set dark";
      };

      Install = {
        WantedBy = [ "graphical-session.target" ];
      };
    };
  };
}