2019-12-27 09:30:06 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.grobi;
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
eitherStrBoolIntList = with types;
|
|
|
|
either str (either bool (either int (listOf str)));
|
2019-12-27 09:30:06 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2019-12-27 09:30:06 +00:00
|
|
|
meta.maintainers = [ maintainers.mbrgm ];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.grobi = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "the grobi display setup daemon";
|
2019-12-27 09:30:06 +00:00
|
|
|
|
|
|
|
executeAfter = mkOption {
|
|
|
|
type = with types; listOf str;
|
2020-02-01 23:39:17 +00:00
|
|
|
default = [ ];
|
2019-12-27 09:30:06 +00:00
|
|
|
example = [ "setxkbmap dvorak" ];
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2019-12-27 09:30:06 +00:00
|
|
|
Commands to be run after an output configuration was
|
|
|
|
changed. The Nix value declared here will be translated to
|
2023-06-30 23:30:13 +00:00
|
|
|
JSON and written to the {option}`execute_after` key
|
|
|
|
in {file}`$XDG_CONFIG_HOME/grobi.conf`.
|
2019-12-27 09:30:06 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
rules = mkOption {
|
|
|
|
type = with types; listOf (attrsOf eitherStrBoolIntList);
|
2020-02-01 23:39:17 +00:00
|
|
|
default = [ ];
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2019-12-27 09:30:06 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
name = "Home";
|
|
|
|
outputs_connected = [ "DP-2" ];
|
|
|
|
configure_single = "DP-2";
|
|
|
|
primary = true;
|
|
|
|
atomic = true;
|
|
|
|
execute_after = [
|
|
|
|
"${pkgs.xorg.xrandr}/bin/xrandr --dpi 96"
|
|
|
|
"${pkgs.xmonad-with-packages}/bin/xmonad --restart";
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "Mobile";
|
|
|
|
outputs_disconnected = [ "DP-2" ];
|
|
|
|
configure_single = "eDP-1";
|
|
|
|
primary = true;
|
|
|
|
atomic = true;
|
|
|
|
execute_after = [
|
|
|
|
"${pkgs.xorg.xrandr}/bin/xrandr --dpi 120"
|
|
|
|
"${pkgs.xmonad-with-packages}/bin/xmonad --restart";
|
|
|
|
];
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2019-12-27 09:30:06 +00:00
|
|
|
These are the rules grobi tries to match to the current
|
|
|
|
output configuration. The rules are evaluated top to bottom,
|
|
|
|
the first matching rule is applied and processing stops. See
|
2023-06-30 23:30:13 +00:00
|
|
|
<https://github.com/fd0/grobi/blob/master/doc/grobi.conf>
|
2019-12-27 09:30:06 +00:00
|
|
|
for more information. The Nix value declared here will be
|
2023-06-30 23:30:13 +00:00
|
|
|
translated to JSON and written to the {option}`rules`
|
|
|
|
key in {file}`$XDG_CONFIG_HOME/grobi.conf`.
|
2019-12-27 09:30:06 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 21:24:27 +00:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.grobi" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2019-12-27 09:30:06 +00:00
|
|
|
systemd.user.services.grobi = {
|
|
|
|
Unit = {
|
|
|
|
Description = "grobi display auto config daemon";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${pkgs.grobi}/bin/grobi watch -v";
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "2s";
|
|
|
|
Environment = "PATH=${pkgs.xorg.xrandr}/bin:${pkgs.bash}/bin";
|
|
|
|
};
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
2019-12-27 09:30:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
xdg.configFile."grobi.conf".text = builtins.toJSON {
|
|
|
|
execute_after = cfg.executeAfter;
|
|
|
|
rules = cfg.rules;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|