mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 05:03:09 +00:00
grobi: add module
This adds a service module for [grobi](https://github.com/fd0/grobi), which can be used to automatically configure monitors/outputs for Xorg via RANDR.
This commit is contained in:
parent
b270fcef2f
commit
b4e8d9869f
3 changed files with 110 additions and 0 deletions
|
@ -1303,6 +1303,14 @@ in
|
|||
A new module is available: 'xsession.windowManager.bspwm'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2020-01-26T12:49:40+00:00";
|
||||
condition = hostPlatform.isLinux;
|
||||
message = ''
|
||||
A new module is available: 'services.grobi'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ let
|
|||
(loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./services/gnome-keyring.nix { })
|
||||
(loadModule ./services/gpg-agent.nix { })
|
||||
(loadModule ./services/grobi.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./services/hound.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./services/kbfs.nix { })
|
||||
|
|
101
modules/services/grobi.nix
Normal file
101
modules/services/grobi.nix
Normal file
|
@ -0,0 +1,101 @@
|
|||
{ 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 "the grobi display setup daemon";
|
||||
|
||||
executeAfter = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
example = [ "setxkbmap dvorak" ];
|
||||
description = ''
|
||||
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</option> key
|
||||
in <filename>~/.config/grobi.conf</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
rules = mkOption {
|
||||
type = with types; listOf (attrsOf eitherStrBoolIntList);
|
||||
default = [];
|
||||
example = literalExample ''
|
||||
[
|
||||
{
|
||||
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 = ''
|
||||
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
|
||||
<link xlink:href="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</option>
|
||||
key in <filename>~/.config/grobi.conf</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
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;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue