blob: f313651483506aa7a34838d4311a56734efce4f5 [file] [log] [blame]
Skyler Grey4e230892024-02-13 22:58:46 +00001{
2 pkgs,
3 config,
4 inputs,
5 system,
6 lib,
7 ...
8}:
9let
Skyler Greya0da6b22024-02-11 22:53:41 +000010 lock = "${pkgs.waylock}/bin/waylock";
Skyler Grey4e230892024-02-13 22:58:46 +000011in
12{
Skyler Grey71b81982024-02-15 18:06:36 +000013 options.chimera = {
Skyler Grey5e344982024-02-15 18:59:45 +000014 input.mouse.scrolling.natural = lib.mkEnableOption "Enable natural scrolling";
15 input.touchpad.scrolling.natural = lib.mkOption {
16 type = lib.types.bool;
17 description = "Enable natural scrolling";
18 default = config.chimera.input.mouse.scrolling.natural;
19 };
Skyler Grey71b81982024-02-15 18:06:36 +000020 input.keyboard = {
21 layout = lib.mkOption {
22 type = lib.types.str;
23 description = "Keyboard layouts, comma seperated";
24 example = "us,de";
25 default = "us";
26 };
27 variant = lib.mkOption {
28 type = lib.types.nullOr lib.types.str;
29 description = "Keyboard layout variants, comma seperated";
30 example = "dvorak";
31 default = null;
32 };
33 };
34 hyprland = {
35 enable = lib.mkEnableOption "Use hyprland as your window manager";
Skyler Grey4e230892024-02-13 22:58:46 +000036
Skyler Grey71b81982024-02-15 18:06:36 +000037 monitors = lib.mkOption {
38 type = lib.types.listOf lib.types.str;
39 description = "List of default monitors to set";
40 default = [ ];
41 };
Skyler Grey4e230892024-02-13 22:58:46 +000042 };
43 };
44
Skyler Grey4e230892024-02-13 22:58:46 +000045 config = lib.mkIf config.chimera.hyprland.enable {
Samuel Shuertdab963e2024-03-23 19:54:28 -040046 chimera.waybar.enable = lib.mkDefault true;
47
Skyler Greyb8bc97b2024-02-25 11:12:08 +000048 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
49 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000050 exec ${pkgs.systemd}/bin/systemd-cat -t hyprland ${pkgs.dbus}/bin/dbus-run-session ${config.wayland.windowManager.hyprland.package}/bin/Hyprland
Skyler Greyb8bc97b2024-02-25 11:12:08 +000051 fi
52 '');
53
54 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
55 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000056 exec ${pkgs.systemd}/bin/systemd-cat -t hyprland ${pkgs.dbus}/bin/dbus-run-session ${config.wayland.windowManager.hyprland.package}/bin/Hyprland
Skyler Greyb8bc97b2024-02-25 11:12:08 +000057 fi
58 '');
59
Skyler Grey4e230892024-02-13 22:58:46 +000060 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +000061
Skyler Grey4e230892024-02-13 22:58:46 +000062 services.fusuma.settings.swipe = lib.mkIf config.chimera.touchpad.enable (
63 let
64 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
65 jq = "${pkgs.jq}/bin/jq";
66 awk = "${pkgs.gawk}/bin/awk";
67 in
68 {
69 "3".up.command = "${hyprctl} dispatch fullscreen 0";
70 "3".down.command = "${hyprctl} dispatch fullscreen 0";
71 "4".down.command = lock;
72 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
73 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
74 }
75 );
Skyler Greya0da6b22024-02-11 22:53:41 +000076
Skyler Grey4e230892024-02-13 22:58:46 +000077 wayland.windowManager.hyprland = {
78 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +000079
Skyler Grey4e230892024-02-13 22:58:46 +000080 xwayland.enable = true;
81 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +000082
Skyler Grey4e230892024-02-13 22:58:46 +000083 settings =
84 let
85 mod = "SUPER";
86 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -050087 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
Skyler Grey4e230892024-02-13 22:58:46 +000088 in
89 {
90 misc = {
91 disable_hyprland_logo = true;
92 disable_splash_rendering = true;
93 };
Skyler Greya0da6b22024-02-11 22:53:41 +000094
Skyler Greye3e18d32024-02-17 11:33:17 +000095 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +000096 "${pkgs.hyprpaper}/bin/hyprpaper"
97 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -040098 "${pkgs.waybar}/bin/waybar"
Samuel Shuert659b5642024-02-23 20:47:43 +000099 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000100
Skyler Grey4e230892024-02-13 22:58:46 +0000101 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000102
Skyler Greyabaa6072024-02-15 19:07:00 +0000103 general = {
104 border_size = 1;
105 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
106 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
107 };
108
Skyler Grey4e230892024-02-13 22:58:46 +0000109 decoration = {
110 rounding = 7;
Skyler Greyabaa6072024-02-15 19:07:00 +0000111 drop_shadow = false;
Skyler Grey4e230892024-02-13 22:58:46 +0000112 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000113
Skyler Grey4e230892024-02-13 22:58:46 +0000114 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000115 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000116 kb_variant =
117 lib.mkIf (config.chimera.input.keyboard.variant != null)
118 config.chimera.input.keyboard.variant;
Skyler Grey5e344982024-02-15 18:59:45 +0000119 natural_scroll = config.chimera.input.mouse.scrolling.natural;
120
121 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000122
Skyler Grey4e230892024-02-13 22:58:46 +0000123 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000124 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000125 };
126 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000127
Skyler Grey4e230892024-02-13 22:58:46 +0000128 xwayland = {
129 force_zero_scaling = true;
130 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000131
Skyler Grey4e230892024-02-13 22:58:46 +0000132 dwindle = {
133 pseudotile = true;
134 smart_split = true;
135 };
136
137 master = {
138 allow_small_split = true;
139 new_is_master = true;
140 };
141
142 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
143
144 bind =
145 [
146 "${mod}, Q, killactive"
147 "${mod}, SPACE, togglefloating"
148 "${mod}, RETURN, exec, ${terminal}"
149 "${mod}, down, movefocus, d"
150 "${mod}, up, movefocus, u"
151 "${mod}, right, movefocus, r"
152 "${mod}, left, movefocus, l"
153 "${mod}, L, exec, ${lock}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000154 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500155 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
Skyler Grey4e230892024-02-13 22:58:46 +0000156 ++ (builtins.concatLists (
157 builtins.genList
158 (
159 x:
160 let
161 ws =
162 let
163 c = (x + 1) / 10;
164 in
165 builtins.toString (x + 1 - (c * 10));
166 in
167 [
168 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
169 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
170 ]
171 )
172 10
173 ));
Skyler Greya0da6b22024-02-11 22:53:41 +0000174
Skyler Grey4e230892024-02-13 22:58:46 +0000175 bindm = [
176 "${mod}, mouse:272, movewindow"
177 "${mod}, mouse:273, resizewindow"
178 ];
179 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000180 };
181 };
Skyler Grey4e230892024-02-13 22:58:46 +0000182}