2017-04-06 12:03:31 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.autorandr;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.autorandr = {
|
|
|
|
enable = mkEnableOption "handling of hotplug and sleep events by autorandr";
|
2018-06-22 22:52:21 +02:00
|
|
|
|
|
|
|
defaultTarget = mkOption {
|
|
|
|
default = "default";
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Fallback if no monitor layout can be detected. See the docs
|
|
|
|
(https://github.com/phillipberndt/autorandr/blob/v1.0/README.md#how-to-use)
|
|
|
|
for further reference.
|
|
|
|
'';
|
|
|
|
};
|
2017-04-06 12:03:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.autorandr ];
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.autorandr ];
|
|
|
|
|
|
|
|
systemd.services.autorandr = {
|
|
|
|
wantedBy = [ "sleep.target" ];
|
2018-06-22 22:52:21 +02:00
|
|
|
description = "Autorandr execution hook";
|
|
|
|
after = [ "sleep.target" ];
|
|
|
|
|
2020-09-09 09:31:27 +02:00
|
|
|
startLimitIntervalSec = 5;
|
|
|
|
startLimitBurst = 1;
|
2018-06-22 22:52:21 +02:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.autorandr}/bin/autorandr --batch --change --default ${cfg.defaultTarget}";
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = false;
|
2022-01-19 21:08:32 +01:00
|
|
|
KillMode = "process";
|
2018-06-22 22:52:21 +02:00
|
|
|
};
|
2017-04-06 12:03:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-04-29 07:21:13 +02:00
|
|
|
meta.maintainers = with maintainers; [ ];
|
2017-04-06 12:03:31 +02:00
|
|
|
}
|