1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-04 18:29:45 +01:00
home-manager/modules/services/grobi.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

102 lines
3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.grobi;
eitherStrBoolIntList = with types;
either str (either bool (either int (listOf str)));
in {
meta.maintainers = [ maintainers.mbrgm ];
options = {
services.grobi = {
enable = mkEnableOption (lib.mdDoc "the grobi display setup daemon");
executeAfter = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "setxkbmap dvorak" ];
description = lib.mdDoc ''
Commands to be run after an output configuration was
changed. The Nix value declared here will be translated to
JSON and written to the {option}`execute_after` key
in {file}`$XDG_CONFIG_HOME/grobi.conf`.
'';
};
rules = mkOption {
type = with types; listOf (attrsOf eitherStrBoolIntList);
default = [ ];
example = literalExpression ''
[
{
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";
];
}
]
'';
description = lib.mdDoc ''
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
<https://github.com/fd0/grobi/blob/master/doc/grobi.conf>
for more information. The Nix value declared here will be
translated to JSON and written to the {option}`rules`
key in {file}`$XDG_CONFIG_HOME/grobi.conf`.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.grobi" pkgs
lib.platforms.linux)
];
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";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
xdg.configFile."grobi.conf".text = builtins.toJSON {
execute_after = cfg.executeAfter;
rules = cfg.rules;
};
};
}