services.autorandr: add module

This commit is contained in:
Gaetan Lepage 2023-01-26 16:08:17 +01:00 committed by Robert Helgesson
parent 4a95852490
commit d1c7730bb7
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
4 changed files with 64 additions and 0 deletions

2
.github/CODEOWNERS vendored
View File

@ -360,6 +360,8 @@ Makefile @thiagokokada
/modules/programs/zsh/prezto.nix @NickHu
/modules/services/autorandr.nix @GaetanLepage
/modules/services/barrier.nix @Kritnich
/tests/modules/services/barrier @Kritnich

View File

@ -907,6 +907,14 @@ in
A new module is available: 'programs.rbenv'.
'';
}
{
time = "2023-02-02T20:49:05+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.autorandr'.
'';
}
];
};
}

View File

@ -203,6 +203,7 @@ let
./programs/zplug.nix
./programs/zsh.nix
./programs/zsh/prezto.nix
./services/autorandr.nix
./services/barrier.nix
./services/betterlockscreen.nix
./services/blueman-applet.nix

View File

@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.autorandr;
in {
meta.maintainers = [ maintainers.GaetanLepage ];
options = {
services.autorandr = {
enable = mkEnableOption "" // {
description = ''
Whether to enable the Autorandr systemd service.
This module is complementary to <code>programs.autorandr</code> which handles the
configuration (profiles).
'';
};
ignoreLid = mkOption {
default = false;
type = types.bool;
description =
"Treat outputs as connected even if their lids are closed.";
};
};
};
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" ];
};
};
}