services.autorandr: add module
This commit is contained in:
parent
4a95852490
commit
d1c7730bb7
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -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'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
53
modules/services/autorandr.nix
Normal file
53
modules/services/autorandr.nix
Normal 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" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue