blob: f8a96ccf343d70b3653f0377e2fa30323dc425af [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
Skyler Grey4e230892024-02-13 22:58:46 +0000152 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000153 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000154 };
155 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000156
Skyler Grey4e230892024-02-13 22:58:46 +0000157 xwayland = {
158 force_zero_scaling = true;
159 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000160
Skyler Grey4e230892024-02-13 22:58:46 +0000161 dwindle = {
162 pseudotile = true;
163 smart_split = true;
164 };
165
166 master = {
167 allow_small_split = true;
Skyler Grey4e230892024-02-13 22:58:46 +0000168 };
169
170 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
171
172 bind =
173 [
174 "${mod}, Q, killactive"
175 "${mod}, SPACE, togglefloating"
176 "${mod}, RETURN, exec, ${terminal}"
177 "${mod}, down, movefocus, d"
178 "${mod}, up, movefocus, u"
179 "${mod}, right, movefocus, r"
180 "${mod}, left, movefocus, l"
181 "${mod}, L, exec, ${lock}"
PineaFan2f02bca2024-04-20 21:21:44 +0100182 "${mod}, R, exec, ${screenshot}"
183 ", Print, exec, ${screenshot}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000184 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500185 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
PineaFan2f02bca2024-04-20 21:21:44 +0100186 ++ (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 +0000187 ++ (builtins.concatLists (
188 builtins.genList
189 (
190 x:
191 let
192 ws =
193 let
194 c = (x + 1) / 10;
195 in
196 builtins.toString (x + 1 - (c * 10));
197 in
198 [
199 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
200 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
201 ]
202 )
203 10
PineaFan2f02bca2024-04-20 21:21:44 +0100204 ))
PineaFan189926e2024-06-11 17:16:16 +0100205 ++ (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 +0100206 ++ [
207 # Volume controls
Skyler Grey69a999e2024-05-23 00:09:10 +0000208 ", XF86AudioRaiseVolume, exec, ${pkgs.pamixer}/bin/pamixer -i ${toString config.chimera.hyprland.keybinds.volumeStep}"
209 ", XF86AudioLowerVolume, exec, ${pkgs.pamixer}/bin/pamixer -d ${toString config.chimera.hyprland.keybinds.volumeStep}"
PineaFand1a8b742024-04-23 21:09:26 +0100210 ", XF86AudioMute, exec, ${pkgs.pamixer}/bin/pamixer -t"
211 # Pause and play
212 ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
213 # Next and previous
214 ", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next"
215 ", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous"
216 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000217
Skyler Grey4e230892024-02-13 22:58:46 +0000218 bindm = [
219 "${mod}, mouse:272, movewindow"
220 "${mod}, mouse:273, resizewindow"
221 ];
PineaFan66e46742024-04-20 20:59:22 +0100222
223 env = lib.mkIf config.chimera.nvidia.enable [
224 "LIBVA_DRIVER_NAME,nvidia"
225 "XDG_SESSION_TYPE,wayland"
226 "GBM_BACKEND,nvidia-drm"
227 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
228 "WLR_NO_HARDWARE_CURSORS,1"
PineaFan2f02bca2024-04-20 21:21:44 +0100229 ];
Skyler Grey4e230892024-02-13 22:58:46 +0000230 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000231 };
Skyler Grey69a999e2024-05-23 00:09:10 +0000232 });
Skyler Grey4e230892024-02-13 22:58:46 +0000233}