fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.2 KiB53 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.autorandr;
6
7in {
8
9  meta.maintainers = [ maintainers.GaetanLepage ];
10
11  options = {
12    services.autorandr = {
13      enable = mkEnableOption "" // {
14        description = ''
15          Whether to enable the Autorandr systemd service.
16          This module is complementary to {option}`programs.autorandr`
17          which handles the configuration (profiles).
18        '';
19      };
20
21      ignoreLid = mkOption {
22        default = false;
23        type = types.bool;
24        description =
25          "Treat outputs as connected even if their lids are closed.";
26      };
27    };
28  };
29
30  config = mkIf cfg.enable {
31    assertions = [
32      (lib.hm.assertions.assertPlatform "services.autorandr" pkgs
33        lib.platforms.linux)
34    ];
35
36    systemd.user.services.autorandr = {
37      Unit = {
38        Description = "autorandr";
39        After = [ "graphical-session-pre.target" ];
40        PartOf = [ "graphical-session.target" ];
41      };
42
43      Service = {
44        Type = "oneshot";
45        ExecStart = "${pkgs.autorandr}/bin/autorandr --change ${
46            optionalString cfg.ignoreLid "--ignore-lid"
47          }";
48      };
49
50      Install.WantedBy = [ "graphical-session.target" ];
51    };
52  };
53}