nix/modules/stuff/autorandr.nix

41 lines
1.2 KiB
Nix
Raw Normal View History

2024-08-01 21:22:47 +02:00
{ 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";
2024-10-16 11:40:24 +02:00
# TODO: proper types for these maybe idk
2024-08-01 21:22:47 +02:00
fingerprint = mkOption {
type = types.attrs;
default = null;
};
config = mkOption {
type = types.attrs;
default = null;
};
};
2024-10-16 11:40:24 +02:00
2024-08-01 21:22:47 +02:00
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" ];
};
};
};
}