fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . grobi ; 8 9eitherStrBoolIntList = with types ; 10either str ( either bool ( either int ( listOf str ))); 11 12in { 13meta . maintainers = [ maintainers . mbrgm ]; 14 15options = { 16services . grobi = { 17enable = mkEnableOption "the grobi display setup daemon" ; 18 19executeAfter = mkOption { 20type = with types ; listOf str ; 21default = [ ]; 22example = [ "setxkbmap dvorak" ]; 23description = '' 24Commands to be run after an output configuration was 25changed. The Nix value declared here will be translated to 26JSON and written to the {option}`execute_after` key 27in {file}`$XDG_CONFIG_HOME/grobi.conf`. 28'' ; 29}; 30 31rules = mkOption { 32type = with types ; listOf ( attrsOf eitherStrBoolIntList ); 33default = [ ]; 34example = literalExpression '' 35[ 36{ 37name = "Home"; 38outputs_connected = [ "DP-2" ]; 39configure_single = "DP-2"; 40primary = true; 41atomic = true; 42execute_after = [ 43" ${ pkgs . xorg . xrandr } /bin/xrandr --dpi 96" 44" ${ pkgs . xmonad-with-packages } /bin/xmonad --restart"; 45]; 46} 47{ 48name = "Mobile"; 49outputs_disconnected = [ "DP-2" ]; 50configure_single = "eDP-1"; 51primary = true; 52atomic = true; 53execute_after = [ 54" ${ pkgs . xorg . xrandr } /bin/xrandr --dpi 120" 55" ${ pkgs . xmonad-with-packages } /bin/xmonad --restart"; 56]; 57} 58] 59'' ; 60description = '' 61These are the rules grobi tries to match to the current 62output configuration. The rules are evaluated top to bottom, 63the first matching rule is applied and processing stops. See 64<https://github.com/fd0/grobi/blob/master/doc/grobi.conf> 65for more information. The Nix value declared here will be 66translated to JSON and written to the {option}`rules` 67key in {file}`$XDG_CONFIG_HOME/grobi.conf`. 68'' ; 69}; 70}; 71}; 72 73config = mkIf cfg . enable { 74assertions = [ 75( lib . hm . assertions . assertPlatform "services.grobi" pkgs 76lib . platforms . linux ) 77]; 78 79systemd . user . services . grobi = { 80Unit = { 81Description = "grobi display auto config daemon" ; 82After = [ "graphical-session-pre.target" ]; 83PartOf = [ "graphical-session.target" ]; 84}; 85 86Service = { 87Type = "simple" ; 88ExecStart = " ${ pkgs . grobi } /bin/grobi watch -v" ; 89Restart = "always" ; 90RestartSec = "2s" ; 91Environment = "PATH= ${ pkgs . xorg . xrandr } /bin: ${ pkgs . bash } /bin" ; 92}; 93 94Install = { WantedBy = [ "graphical-session.target" ]; }; 95}; 96 97xdg . configFile . "grobi.conf" . text = builtins . toJSON { 98execute_after = cfg . executeAfter ; 99rules = cfg . rules ; 100}; 101}; 102}