2023-01-26 16:08:17 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let cfg = config.services.autorandr;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
meta.maintainers = [ maintainers.GaetanLepage ];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.autorandr = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
description = ''
|
2023-01-26 16:08:17 +01:00
|
|
|
Whether to enable the Autorandr systemd service.
|
2023-07-01 09:48:09 +02:00
|
|
|
This module is complementary to {option}`programs.autorandr`
|
|
|
|
which handles the configuration (profiles).
|
2023-01-26 16:08:17 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ignoreLid = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description =
|
2023-07-02 01:45:18 +02:00
|
|
|
"Treat outputs as connected even if their lids are closed.";
|
2023-01-26 16:08:17 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.autorandr" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.user.services.autorandr = {
|
|
|
|
Unit = {
|
|
|
|
Description = "autorandr";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${pkgs.autorandr}/bin/autorandr --change ${
|
|
|
|
optionalString cfg.ignoreLid "--ignore-lid"
|
|
|
|
}";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|