blob: fab449e7f8bbbd5b905cebfad9f6f6e0b50bf470 [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 Grey97831642024-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 = {
36 volumeStep = lib.mkOption {
37 type = lib.types.int;
38 description = "Amount to increase volume by when media keys are pressed in %";
39 example = "5";
40 default = 5;
41 };
42 extraBinds = let
43 binds = lib.types.submodule {
44 options = {
45 meta = lib.mkOption {
46 type = lib.types.nullOr lib.types.str;
47 description = "Additional modifier keys space seperated";
48 default = null;
49 };
50 key = lib.mkOption {
51 type = lib.types.str;
52 description = "Final key";
53 };
54 function = lib.mkOption {
55 type = lib.types.str;
56 description = "Hyprland bind function";
57 };
58 };
59 };
60 in lib.mkOption {
61 type = lib.types.listOf binds;
62 description = "Extra keybinds to add";
63 default = [ ];
64 };
65 };
Skyler Grey4e230892024-02-13 22:58:46 +000066 };
67 };
Skyler Grey97831642024-05-23 00:09:10 +000068 config = lib.mkIf config.chimera.hyprland.enable (let
69 lock = "${pkgs.waylock}/bin/waylock";
70 in {
71 chimera.wayland.enable = true;
Samuel Shuertdab963e2024-03-23 19:54:28 -040072
Skyler Greyb8bc97b2024-02-25 11:12:08 +000073 programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
74 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000075 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 +000076 fi
77 '');
78
79 programs.zsh.profileExtra = lib.mkIf config.chimera.shell.zsh.enable (lib.mkBefore ''
80 if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
Skyler Greyfb254d22024-03-03 13:03:22 +000081 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 +000082 fi
83 '');
84
Skyler Grey4e230892024-02-13 22:58:46 +000085 home.packages = [ pkgs.hyprpicker ];
Skyler Greya0da6b22024-02-11 22:53:41 +000086
Skyler Grey4e230892024-02-13 22:58:46 +000087 services.fusuma.settings.swipe = lib.mkIf config.chimera.touchpad.enable (
88 let
89 hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
90 jq = "${pkgs.jq}/bin/jq";
91 awk = "${pkgs.gawk}/bin/awk";
92 in
93 {
94 "3".up.command = "${hyprctl} dispatch fullscreen 0";
95 "3".down.command = "${hyprctl} dispatch fullscreen 0";
96 "4".down.command = lock;
97 "3".left.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1+1}')";
98 "3".right.command = "${hyprctl} dispatch workspace $(${hyprctl} activeworkspace -j | ${jq} .id | ${awk} '{print $1-1}')";
99 }
100 );
Skyler Greya0da6b22024-02-11 22:53:41 +0000101
Skyler Grey4e230892024-02-13 22:58:46 +0000102 wayland.windowManager.hyprland = {
103 enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000104
Skyler Grey4e230892024-02-13 22:58:46 +0000105 xwayland.enable = true;
106 systemd.enable = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000107
Skyler Grey4e230892024-02-13 22:58:46 +0000108 settings =
109 let
110 mod = "SUPER";
111 terminal = "${pkgs.kitty}/bin/kitty";
Samuel Shuert004d0752024-03-02 11:57:09 -0500112 menu = (if config.chimera.runner.anyrun.enable then "${inputs.anyrun.packages.${system}.anyrun}/bin/anyrun" else "");
PineaFan2f02bca2024-04-20 21:21:44 +0100113 screenshot = "${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp -d)\" - | ${pkgs.wl-clipboard}/bin/wl-copy";
Skyler Grey4e230892024-02-13 22:58:46 +0000114 in
115 {
116 misc = {
117 disable_hyprland_logo = true;
118 disable_splash_rendering = true;
119 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000120
Skyler Greye3e18d32024-02-17 11:33:17 +0000121 exec-once = [
Samuel Shuert659b5642024-02-23 20:47:43 +0000122 "${pkgs.hyprpaper}/bin/hyprpaper"
123 "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
Samuel Shuertdab963e2024-03-23 19:54:28 -0400124 "${pkgs.waybar}/bin/waybar"
Skyler Grey97831642024-05-23 00:09:10 +0000125 ] ++ config.chimera.hyprland.startupApplications;
Skyler Greya0da6b22024-02-11 22:53:41 +0000126
Skyler Grey4e230892024-02-13 22:58:46 +0000127 monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000128
Skyler Greyabaa6072024-02-15 19:07:00 +0000129 general = {
130 border_size = 1;
131 "col.active_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
132 "col.inactive_border" = "rgba(${config.chimera.theme.colors.Surface0.hex}FF)";
133 };
134
Skyler Grey4e230892024-02-13 22:58:46 +0000135 decoration = {
PineaFan2f02bca2024-04-20 21:21:44 +0100136 rounding = config.chimera.hyprland.window.rounding;
Skyler Greyabaa6072024-02-15 19:07:00 +0000137 drop_shadow = false;
PineaFan2f02bca2024-04-20 21:21:44 +0100138 blur.size = config.chimera.hyprland.window.blur;
Skyler Grey4e230892024-02-13 22:58:46 +0000139 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000140
Skyler Grey4e230892024-02-13 22:58:46 +0000141 input = {
Skyler Grey71b81982024-02-15 18:06:36 +0000142 kb_layout = config.chimera.input.keyboard.layout;
Skyler Greyec50d242024-02-15 23:09:46 +0000143 kb_variant =
144 lib.mkIf (config.chimera.input.keyboard.variant != null)
145 config.chimera.input.keyboard.variant;
Skyler Grey5e344982024-02-15 18:59:45 +0000146 natural_scroll = config.chimera.input.mouse.scrolling.natural;
147
148 numlock_by_default = true;
Skyler Greya0da6b22024-02-11 22:53:41 +0000149
Skyler Grey4e230892024-02-13 22:58:46 +0000150 touchpad = {
Skyler Grey5e344982024-02-15 18:59:45 +0000151 natural_scroll = config.chimera.input.touchpad.scrolling.natural;
Skyler Grey4e230892024-02-13 22:58:46 +0000152 };
153 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000154
Skyler Grey4e230892024-02-13 22:58:46 +0000155 xwayland = {
156 force_zero_scaling = true;
157 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000158
Skyler Grey4e230892024-02-13 22:58:46 +0000159 dwindle = {
160 pseudotile = true;
161 smart_split = true;
162 };
163
164 master = {
165 allow_small_split = true;
166 new_is_master = true;
167 };
168
169 windowrulev2 = [ "opacity 1.0 0.85,title:(.*)" ];
170
171 bind =
172 [
173 "${mod}, Q, killactive"
174 "${mod}, SPACE, togglefloating"
175 "${mod}, RETURN, exec, ${terminal}"
176 "${mod}, down, movefocus, d"
177 "${mod}, up, movefocus, u"
178 "${mod}, right, movefocus, r"
179 "${mod}, left, movefocus, l"
180 "${mod}, L, exec, ${lock}"
PineaFan2f02bca2024-04-20 21:21:44 +0100181 "${mod}, R, exec, ${screenshot}"
182 ", Print, exec, ${screenshot}"
Skyler Greya0da6b22024-02-11 22:53:41 +0000183 ]
Samuel Shuert004d0752024-03-02 11:57:09 -0500184 ++ (if config.chimera.runner.enable then [ "${mod}, D, exec, ${menu}" ] else [])
PineaFan2f02bca2024-04-20 21:21:44 +0100185 ++ (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 +0000186 ++ (builtins.concatLists (
187 builtins.genList
188 (
189 x:
190 let
191 ws =
192 let
193 c = (x + 1) / 10;
194 in
195 builtins.toString (x + 1 - (c * 10));
196 in
197 [
198 "${mod}, ${ws}, workspace, ${toString (x + 1)}"
199 "${mod} SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}"
200 ]
201 )
202 10
PineaFan2f02bca2024-04-20 21:21:44 +0100203 ))
Skyler Grey97831642024-05-23 00:09:10 +0000204 ++ (builtins.map (item: "SUPER_${item.meta}, ${item.key}, ${item.function}") config.chimera.hyprland.keybinds.extraBinds)
PineaFand1a8b742024-04-23 21:09:26 +0100205 ++ [
206 # Volume controls
Skyler Grey97831642024-05-23 00:09:10 +0000207 ", XF86AudioRaiseVolume, exec, ${pkgs.pamixer}/bin/pamixer -i ${toString config.chimera.hyprland.keybinds.volumeStep}"
208 ", XF86AudioLowerVolume, exec, ${pkgs.pamixer}/bin/pamixer -d ${toString config.chimera.hyprland.keybinds.volumeStep}"
PineaFand1a8b742024-04-23 21:09:26 +0100209 ", XF86AudioMute, exec, ${pkgs.pamixer}/bin/pamixer -t"
210 # Pause and play
211 ", XF86AudioPlay, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
212 # Next and previous
213 ", XF86AudioNext, exec, ${pkgs.playerctl}/bin/playerctl next"
214 ", XF86AudioPrev, exec, ${pkgs.playerctl}/bin/playerctl previous"
215 ];
Skyler Greya0da6b22024-02-11 22:53:41 +0000216
Skyler Grey4e230892024-02-13 22:58:46 +0000217 bindm = [
218 "${mod}, mouse:272, movewindow"
219 "${mod}, mouse:273, resizewindow"
220 ];
PineaFan66e46742024-04-20 20:59:22 +0100221
222 env = lib.mkIf config.chimera.nvidia.enable [
223 "LIBVA_DRIVER_NAME,nvidia"
224 "XDG_SESSION_TYPE,wayland"
225 "GBM_BACKEND,nvidia-drm"
226 "__GLX_VENDOR_LIBRARY_NAME,nvidia"
227 "WLR_NO_HARDWARE_CURSORS,1"
PineaFan2f02bca2024-04-20 21:21:44 +0100228 ];
Skyler Grey4e230892024-02-13 22:58:46 +0000229 };
Skyler Greya0da6b22024-02-11 22:53:41 +0000230 };
Skyler Grey97831642024-05-23 00:09:10 +0000231 });
Skyler Grey4e230892024-02-13 22:58:46 +0000232}