diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index 87ed2be..987c719 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -20,8 +20,10 @@ webis.enable = true; impermanence.enable = true; }; - programs.hyprland.enable = true; - programs.gitbutler.enable = true; + programs.hyprland = { + enable = true; + monitors.DP-3.scale = "auto"; + }; programs.exercism.enable = true; }; diff --git a/modules/programs/hyprland/_config.nix b/modules/programs/hyprland/_config.nix index 8731021..18a6c5b 100644 --- a/modules/programs/hyprland/_config.nix +++ b/modules/programs/hyprland/_config.nix @@ -3,10 +3,18 @@ , ... }: -with lib; let + inherit (lib) concatStringsSep flip boolToString mapAttrsToList; cfg = config.my.programs.hyprland; + mkMonitor = { name, resolution, position, scale, disabled, extra }: + if disabled + then "monitor=${name},disabled" + else "monitor=${name},${resolution},${position},${scale},${extra}"; + + monitorsList = mapAttrsToList (name: value: { name = name; } // value) cfg.monitors; + monitors = map mkMonitor monitorsList; + mkRule = rule: windowRegexes: "windowrulev2 = ${rule},${concatStringsSep "," windowRegexes}"; mkRules = rules: windowRegexes: concatStringsSep "\n" (map (flip mkRule windowRegexes) rules); in @@ -17,7 +25,7 @@ in # # See https://wiki.hyprland.org/Configuring/Monitors/ - ${concatLines (map (x: "monitor=${x}") cfg.monitors)} + ${concatStringsSep "\n" monitors} # See https://wiki.hyprland.org/Configuring/Keywords/ for more diff --git a/modules/programs/hyprland/default.nix b/modules/programs/hyprland/default.nix index 4c6bed1..76caa5c 100644 --- a/modules/programs/hyprland/default.nix +++ b/modules/programs/hyprland/default.nix @@ -5,8 +5,8 @@ , ... } @ args: -with lib; let + inherit (lib) mkOption mkEnableOption mkIf types getExe genAttrs optionalAttrs optional; cfg = config.my.programs.hyprland; hyprland = inputs.hyprland.packages.${pkgs.system}.default; @@ -31,9 +31,38 @@ in default = [ "de" "us" ]; }; monitors = mkOption { - type = types.listOf types.str; - description = "monitor settings"; - default = [ ",preferred,auto,1" ]; + type = types.attrsOf ( + let + sub = types.submodule { + options = { + resolution = mkOption { + type = types.strMatching "\(preferred\)|\([[:digit:]]+x[[:digit:]]+\(@[[:digit:]]+\)\?\)"; + default = "preferred"; + }; + position = mkOption { + type = types.strMatching "\(auto\)|\(-\?[[:digit:]]+x-?[[:digit:]]+\)"; + default = "auto"; + }; + disabled = mkEnableOption "disabled"; + scale = mkOption { + type = types.oneOf [ types.float (types.strMatching "auto") ]; + default = 1.0; + apply = x: if lib.isFloat x then lib.strings.floatToString x else x; + }; + extra = mkOption { + type = types.listOf types.str; + default = [ ]; + apply = lib.concatStringsSep ","; + }; + }; + }; + in + sub + ); + description = "monitor setting"; + default = { + "" = { }; + }; }; extraConfig = mkOption { type = types.str; @@ -51,6 +80,7 @@ in # foot.enable = true; kitty.enable = true; rofi.enable = true; + hyprland.monitors."" = lib.mkDefault { }; }; wallpapers.enable = true; services = {