blob: 5dee95f41badfb28aa96d5c6a25fc39edb38fd61 [file] [log] [blame]
Skyler Grey4e230892024-02-13 22:58:46 +00001{
2 pkgs,
3 config,
4 inputs,
5 system,
6 lib,
7 ...
8}:
Skyler Grey4e230892024-02-13 22:58:46 +00009{
Skyler Grey71b81982024-02-15 18:06:36 +000010 options.chimera = {
Skyler Grey71b81982024-02-15 18:06:36 +000011 hyprland = {
12 enable = lib.mkEnableOption "Use hyprland as your window manager";
Skyler Grey71b81982024-02-15 18:06:36 +000013 monitors = lib.mkOption {
14 type = lib.types.listOf lib.types.str;
15 description = "List of default monitors to set";
16 default = [ ];
17 };
PineaFan2f02bca2024-04-20 21:21:44 +010018 window = {
19 rounding = lib.mkOption {
20 type = lib.types.int;
21 description = "How round the windows should be";
22 default = 7;
23 };
24 blur = lib.mkOption {
25 type = lib.types.int;
26 description = "How blurred the wallpaper under innactive windows should be";
27 default = 8;
28 };
29 };
Skyler Grey69a999e2024-05-23 00:09:10 +000030 startupApplications = lib.mkOption {
31 type = lib.types.listOf lib.types.str;
32 description = "List of commands to run on hyprland start";
33 default = [ ];
34 };
35 keybinds = {
Samuel Shuerta1cea952024-08-23 10:59:43 -040036 appleMagic = lib.mkEnableOption "Emulate PC keys on Apple Magic Keyboard";
Skyler Grey69a999e2024-05-23 00:09:10 +000037 volumeStep = lib.mkOption {
38 type = lib.types.int;
39 description = "Amount to increase volume by when media keys are pressed in %";
40 example = "5";
41 default = 5;
42 };
43 extraBinds = let
44 binds = lib.types.submodule {
45 options = {
46 meta = lib.mkOption {
47 type = lib.types.nullOr lib.types.str;
48 description = "Additional modifier keys space seperated";
49 default = null;
50 };
51 key = lib.mkOption {
52 type = lib.types.str;
53 description = "Final key";
54 };
55 function = lib.mkOption {
56 type = lib.types.str;
57 description = "Hyprland bind function";
58 };
59 };
60 };
61 in lib.mkOption {
62 type = lib.types.listOf binds;
63 description = "Extra keybinds to add";
64 default = [ ];
65 };
66 };
Skyler Grey4e230892024-02-13 22:58:46 +000067 };
68 };
Skyler Grey69a999e2024-05-23 00:09:10 +000069 config = lib.mkIf config.chimera.hyprland.enable (let
70 lock = "${pkgs.waylock}/bin/waylock";
71 in {
72 chimera.wayland.enable = true;
Samuel Shuertdab963e2024-03-23 19:54:28 -040073
Skyler Greyb8bc97b2024-02-25 11:12:08 +000074 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
75 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000076 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 +000077 fi
78 '');
79
80 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
81 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000082 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 +000083 fi
84 '');
85
Skyler Grey4e230892024-02-13 22:58:46 +000086 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +000087
Samuel Shuertf5136892024-06-20 21:04:47 -040088 services.fusuma.settings.swipe = lib.mkIf config.chimera.input.touchpad.enable (
Skyler Grey4e230892024-02-13 22:58:46 +000089 let
90 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
91 jq = "${pkgs.jq}/bin/jq";
92 awk = "${pkgs.gawk}/bin/awk";
93 in
94 {
95 "3".up.command = "${hyprctl} dispatch fullscreen 0";
96 "3".down.command = "${hyprctl} dispatch fullscreen 0";
97 "4".down.command = lock;
98 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
99 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
100 }
101 );
Skyler Greya0da6b22024-02-11 22:53:41 +0000102
Skyler Grey4e230892024-02-13 22:58:46 +0000103 wayland.windowManager.hyprland = {
104 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000105
Skyler Grey4e230892024-02-13 22:58:46 +0000106 xwayland.enable = true;
107 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000108
Skyler Grey4e230892024-02-13 22:58:46 +0000109 settings =
110 let
111 mod = "SUPER";
112 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -0500113 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
PineaFan2f02bca2024-04-20 21:21:44 +0100114 screenshot = "${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp -d)\" - | ${pkgs.wl-clipboard}/bin/wl-copy";
Skyler Grey4e230892024-02-13 22:58:46 +0000115 in
116 {
117 misc = {
118 disable_hyprland_logo = true;
119 disable_splash_rendering = true;
120 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000121
Skyler Greye3e18d32024-02-17 11:33:17 +0000122 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +0000123 "${pkgs.hyprpaper}/bin/hyprpaper"
124 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -0400125 "${pkgs.waybar}/bin/waybar"
Skyler Grey69a999e2024-05-23 00:09:10 +0000126 ] ++ config.chimera.hyprland.startupApplications;
Skyler Greya0da6b22024-02-11 22:53:41 +0000127
Skyler Grey4e230892024-02-13 22:58:46 +0000128 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000129
Skyler Greyabaa6072024-02-15 19:07:00 +0000130 general = {
131 border_size = 1;
132 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
133 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
134 };
135
Skyler Grey4e230892024-02-13 22:58:46 +0000136 decoration = {
PineaFan2f02bca2024-04-20 21:21:44 +0100137 rounding = config.chimera.hyprland.window.rounding;
Skyler Greyabaa6072024-02-15 19:07:00 +0000138 drop_shadow = false;
PineaFan2f02bca2024-04-20 21:21:44 +0100139 blur.size = config.chimera.hyprland.window.blur;
Skyler Grey4e230892024-02-13 22:58:46 +0000140 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000141
Skyler Grey4e230892024-02-13 22:58:46 +0000142 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000143 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000144 kb_variant =
145 lib.mkIf (config.chimera.input.keyboard.variant != null)
146 config.chimera.input.keyboard.variant;
Samuel Shuerta1cea952024-08-23 10:59:43 -0400147 kb_options = lib.mkIf (config.chimera.hyprland.keybinds.appleMagic) "apple:alupckeys";
Skyler Grey5e344982024-02-15 18:59:45 +0000148 natural_scroll = config.chimera.input.mouse.scrolling.natural;
149
150 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000151
PineaFancaf131b2024-10-04 20:15:31 +0100152 sensitivity = config.chimera.input.mouse.sensitivity;
153
Skyler Grey4e230892024-02-13 22:58:46 +0000154 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000155 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
PineaFancaf131b2024-10-04 20:15:31 +0100156 scroll_factor = config.chimera.input.touchpad.scrolling.factor;
157 clickfinger_behavior = true;
158 tap-to-click = config.chimera.input.touchpad.tapToClick;
Skyler Grey4e230892024-02-13 22:58:46 +0000159 };
160 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000161
PineaFancaf131b2024-10-04 20:15:31 +0100162 gestures = lib.mkIf config.chimera.input.touchpad.enable {
163 workspace_swipe = true;
164 };
165
Skyler Grey4e230892024-02-13 22:58:46 +0000166 xwayland = {
167 force_zero_scaling = true;
168 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000169
Skyler Grey4e230892024-02-13 22:58:46 +0000170 dwindle = {
171 pseudotile = true;
172 smart_split = true;
173 };
174
175 master = {
176 allow_small_split = true;
Skyler Grey4e230892024-02-13 22:58:46 +0000177 };
178
179 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
180
181 bind =
182 [
183 "${mod}, Q, killactive"
184 "${mod}, SPACE, togglefloating"
185 "${mod}, RETURN, exec, ${terminal}"
186 "${mod}, down, movefocus, d"
187 "${mod}, up, movefocus, u"
188 "${mod}, right, movefocus, r"
189 "${mod}, left, movefocus, l"
190 "${mod}, L, exec, ${lock}"
PineaFan2f02bca2024-04-20 21:21:44 +0100191 "${mod}, R, exec, ${screenshot}"
192 ", Print, exec, ${screenshot}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000193 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500194 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
PineaFan2f02bca2024-04-20 21:21:44 +0100195 ++ (if lib.and config.chimera.input.keybinds.alternativeSearch.enable config.chimera.runner.enable then [ "ALT, SPACE, exec, ${menu}" ] else [])
Skyler Grey4e230892024-02-13 22:58:46 +0000196 ++ (builtins.concatLists (
197 builtins.genList
198 (
199 x:
200 let
201 ws =
202 let
203 c = (x + 1) / 10;
204 in
205 builtins.toString (x + 1 - (c * 10));
206 in
207 [
208 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
209 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
210 ]
211 )
212 10
PineaFan2f02bca2024-04-20 21:21:44 +0100213 ))
PineaFan189926e2024-06-11 17:16:16 +0100214 ++ (builtins.map (item: (if item.meta != null then "SUPER_${item.meta}" else "SUPER") + ", ${item.key}, ${item.function}") config.chimera.hyprland.keybinds.extraBinds)
PineaFand1a8b742024-04-23 21:09:26 +0100215 ++ [
216 # Volume controls
Skyler Grey69a999e2024-05-23 00:09:10 +0000217 ", XF86AudioRaiseVolume, exec, ${pkgs.pamixer}/bin/pamixer -i ${toString config.chimera.hyprland.keybinds.volumeStep}"
218 ", XF86AudioLowerVolume, exec, ${pkgs.pamixer}/bin/pamixer -d ${toString config.chimera.hyprland.keybinds.volumeStep}"
PineaFand1a8b742024-04-23 21:09:26 +0100219 ", XF86AudioMute, exec, ${pkgs.pamixer}/bin/pamixer -t"
220 # Pause and play
221 ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
222 # Next and previous
223 ", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next"
224 ", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous"
225 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000226
Skyler Grey4e230892024-02-13 22:58:46 +0000227 bindm = [
228 "${mod}, mouse:272, movewindow"
229 "${mod}, mouse:273, resizewindow"
230 ];
PineaFan66e46742024-04-20 20:59:22 +0100231
232 env = lib.mkIf config.chimera.nvidia.enable [
233 "LIBVA_DRIVER_NAME,nvidia"
234 "XDG_SESSION_TYPE,wayland"
235 "GBM_BACKEND,nvidia-drm"
236 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
237 "WLR_NO_HARDWARE_CURSORS,1"
PineaFan2f02bca2024-04-20 21:21:44 +0100238 ];
Skyler Grey4e230892024-02-13 22:58:46 +0000239 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000240 };
Skyler Grey69a999e2024-05-23 00:09:10 +0000241 });
Skyler Grey4e230892024-02-13 22:58:46 +0000242}