nix/modules/stuff/autorandr.nix
2024-10-16 11:40:24 +02:00

41 lines
No EOL
1.2 KiB
Nix

{ lib, pkgs, config, ...}: let
inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.chuj.stuff.autorandr;
user = config.chuj.system.user;
in {
options.chuj.stuff.autorandr = {
enable = mkEnableOption "autorandr";
# TODO: proper types for these maybe idk
fingerprint = mkOption {
type = types.attrs;
default = null;
};
config = mkOption {
type = types.attrs;
default = null;
};
};
config = mkIf cfg.enable {
home-manager.users.${user} = {
programs.autorandr = {
enable = true;
profiles."main" = { inherit (cfg) fingerprint config; };
};
# the autorandr service from home-manager sucks, can't customize flags
services.autorandr.enable = false;
systemd.user.services.autorandr = {
Unit = {
Description = "autorandr";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.autorandr}/bin/autorandr --match-edid -l main";
};
Install.WantedBy = [ "graphical-session.target" ];
};
};
};
}