many improvements
This commit is contained in:
		
							
								
								
									
										30
									
								
								modules/home-manager/hypr/hyprland/autostart.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								modules/home-manager/hypr/hyprland/autostart.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| {inputs, pkgs, lib, config, ...}: | ||||
| let | ||||
|   cfg = config.nix-config.hypr; | ||||
| in | ||||
| { | ||||
|   options = { | ||||
|     nix-config.hypr.autostartApps = lib.mkOption { | ||||
|       type = lib.types.listOf lib.types.str; | ||||
|       default = [ | ||||
|         "gnome-keyring-daemon --start --components=secrets" | ||||
|         "wl-paste --watch cliphist store" | ||||
|         "${lib.getExe pkgs.waybar}" | ||||
|         "${lib.getExe pkgs.hypridle}" | ||||
|         "${pkgs.owncloud-client}" | ||||
|         "${lib.getExe pkgs.keepassxc}" | ||||
|       ]; | ||||
|       description = "List of applications to start automatically in Hyprland."; | ||||
|     }; | ||||
|   }; | ||||
|  | ||||
|   config = { | ||||
|     wayland.windowManager.hyprland = { | ||||
|       enable = true; | ||||
|       systemd.enable = true; | ||||
|       settings = { | ||||
|         exec-once = cfg.autostartApps; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										9
									
								
								modules/home-manager/hypr/hyprland/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								modules/home-manager/hypr/hyprland/default.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| { | ||||
|   imports = [ | ||||
|     ./autostart.nix | ||||
|     ./general.nix | ||||
|     ./keybinds.nix | ||||
|     ./layouts.nix | ||||
|     ./packages.nix | ||||
|   ]; | ||||
| } | ||||
							
								
								
									
										133
									
								
								modules/home-manager/hypr/hyprland/general.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								modules/home-manager/hypr/hyprland/general.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,133 @@ | ||||
| {inputs, pkgs, lib, config, ...}: | ||||
| let | ||||
|   cfg = config.nix-config.hypr; | ||||
| in | ||||
| { | ||||
|   options = { | ||||
|     nix-config.hypr.internal-screen.resolution = lib.mkOption { type = lib.types.str; }; | ||||
|     nix-config.hypr.internal-screen.scale = lib.mkOption { type = lib.types.str; }; | ||||
|     nix-config.hypr.browser = lib.mkOption { | ||||
|       type = lib.types.str; | ||||
|       default = "firefox"; | ||||
|       description = "The browser to use in Hyprland."; | ||||
|     }; | ||||
|     nix-config.hypr.ide = lib.mkOption { | ||||
|       type = lib.types.str; | ||||
|       default = "code"; | ||||
|       description = "The IDE to use in Hyprland."; | ||||
|     }; | ||||
|   }; | ||||
|  | ||||
|   config = { | ||||
|     wayland.windowManager.hyprland = { | ||||
|       enable = true; | ||||
|       systemd.enable = true; | ||||
|       settings = { | ||||
|         general = { | ||||
|           resize_on_border = true; | ||||
|           gaps_in = 5; | ||||
|           gaps_out = 5; | ||||
|           border_size = 1; | ||||
|           "col.active_border" = "rgb(98971A) rgb(CC241D) 45deg"; | ||||
|           layout = "master"; | ||||
|         }; | ||||
|  | ||||
|       input = { | ||||
|         kb_layout = "de"; | ||||
|         # remap caps lock to ctrl | ||||
|         kb_options = "ctrl:nocaps"; | ||||
|         numlock_by_default = true; | ||||
|         # mouse input should be unchanged | ||||
|         natural_scroll = false; | ||||
|         sensitivity = 0.3; | ||||
|         touchpad = { | ||||
|           disable_while_typing = false; | ||||
|           natural_scroll = true; | ||||
|         }; | ||||
|       }; | ||||
|  | ||||
|       device = { | ||||
|         name = "syna329a:00-06cb:cd4f-touchpad"; | ||||
|         sensitivity = 0.5; | ||||
|       }; | ||||
|  | ||||
|       gestures = { | ||||
|         workspace_swipe = true; | ||||
|         workspace_swipe_fingers = 4; | ||||
|         workspace_swipe_touch = true; | ||||
|       }; | ||||
|  | ||||
|       decoration = { | ||||
|         rounding = 7; | ||||
|         # active_opacity = 0.95; | ||||
|         inactive_opacity = 0.9; | ||||
|  | ||||
|         shadow = { | ||||
|           enabled = false; | ||||
|         }; | ||||
|  | ||||
|         # blur = { | ||||
|         #   enabled = true; | ||||
|         #   size = 5; | ||||
|         #   passes = 2; | ||||
|         # }; | ||||
|  | ||||
|         # blur is set on a per-program basis | ||||
|         windowrulev2 = [ | ||||
|           # kitty should behave like a floating window | ||||
|           "animation popin, class:kitty" | ||||
|           "move cursor -50% -50%, class:kitty" | ||||
|           "float, class:kitty" | ||||
|           "size 50% 50%, class:kitty" | ||||
|  | ||||
|           # blur the launcher background | ||||
|           # "blur 10, class:${config.nix-config.launcher.name}" | ||||
|  | ||||
|           # some more floating windows | ||||
|           "float, class:org.gnome.Settings" | ||||
|           "float, class:desktopclient.owncloud.com" | ||||
|           "float, class:org.keepassxc.KeePassXC" | ||||
|           "float, title:^(Picture-in-Picture)$" | ||||
|           "float, class:org.gnome.Nautilus" | ||||
|           # when there is a single window, deactivate border and gaps | ||||
|           # "border_size 0, onworkspace:w[tv1], " | ||||
|         ]; | ||||
|       }; | ||||
|  | ||||
|       monitor = [ | ||||
|         # the internal monitor, always at the "center" | ||||
|         "eDP-1, ${cfg.internal-screen.resolution}, 0x0, ${cfg.internal-screen.scale}" | ||||
|  | ||||
|         # Samsung monitors at irchel (matching the description) | ||||
|         "desc:Samsung Electric Company LS27D80xU, 2560x1440@59.95, auto-up, 1" | ||||
|  | ||||
|         ", preferred, auto-up, auto" # automatically add any newly detected monitor | ||||
|       ]; | ||||
|  | ||||
|       xwayland = { | ||||
|         enabled = true; | ||||
|         force_zero_scaling = true; | ||||
|       }; | ||||
|  | ||||
|       env = [ | ||||
|         # force apps to use wayland | ||||
|         "NIXOS_OZONE_WL, 1" | ||||
|         "ELECTRON_OZONE_PLATFORM_HINT, wayland" | ||||
|         # set the scale factor for GDK apps | ||||
|         "GDK_SCALE, ${cfg.internal-screen.scale}" | ||||
|         # set the scale factor for QT apps | ||||
|         # "QT_SCALE_FACTOR, ${cfg.internal-screen.scale}" | ||||
|         "QT_SCALE_FACTOR, 1.1" | ||||
|         # set the scale factor for GTK apps | ||||
|       ]; | ||||
|     }; | ||||
|  | ||||
|       plugins = [ | ||||
|         # Global overview | ||||
|         pkgs.hyprlandPlugins.hyprspace | ||||
|         # Touch gestures | ||||
|         pkgs.hyprlandPlugins.hyprgrass | ||||
|       ]; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										135
									
								
								modules/home-manager/hypr/hyprland/keybinds.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								modules/home-manager/hypr/hyprland/keybinds.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| {inputs, pkgs, lib, config, ...}: | ||||
| let | ||||
|   cfg = config.nix-config.hypr; | ||||
| in | ||||
| { | ||||
|   config = { | ||||
|     wayland.windowManager.hyprland = { | ||||
|       enable = true; | ||||
|       systemd.enable = true; | ||||
|       settings = { | ||||
|         "$mod" = "SUPER"; | ||||
|  | ||||
|         # Global bindings | ||||
|         bind = [ | ||||
|           # Launch applications | ||||
|           "$mod, space, exec, ${lib.getExe config.nix-config.launcher}" | ||||
|           "$mod, return, exec, kitty" | ||||
|           "$mod, b, exec, ${cfg.browser}" | ||||
|           "$mod, s, exec, ${cfg.ide}" | ||||
|           "$mod, e, exec, nautilus" | ||||
|  | ||||
|           # Lock screen | ||||
|           "$mod, l, exec, loginctl lock-session" | ||||
|  | ||||
|           # Clipboard management | ||||
|           "$mod, V, exec, cliphist list | ${lib.getExe config.nix-config.launcher} --dmenu | cliphist decode | wl-copy" | ||||
|  | ||||
|           # Close window | ||||
|           "$mod, Q, killactive," | ||||
|           # Force close window | ||||
|           # "$mod+Shift, Q, forcekillactive," | ||||
|  | ||||
|           # Toggle Floating and reduce size | ||||
|           "$mod, f, togglefloating," | ||||
|           "$mod, f, resizeactive, 50% 50%," | ||||
|  | ||||
|           # "$mod, P, pseudo, " # dwindle | ||||
|           # "$mod, J, togglesplit, " # dwindle | ||||
|           # Toggle fullscreen | ||||
|           "$mod+Shift, f, fullscreen," | ||||
|  | ||||
|           # Alt-tab alternative | ||||
|           "$mod, Tab, cyclenext," | ||||
|           "$mod, Tab, bringactivetotop," | ||||
|  | ||||
|           # Move the window | ||||
|           "$mod+Shift, left, movewindow, l" | ||||
|           "$mod+Shift, right, movewindow, r" | ||||
|           "$mod+Shift, up, movewindow, u" | ||||
|           "$mod+Shift, down, movewindow, d" | ||||
|  | ||||
|           "$mod+Ctrl, left, movetoworkspace, -1" | ||||
|           "$mod+Ctrl, right, movetoworkspace, +1" | ||||
|  | ||||
|           # Switch workspace | ||||
|           "$mod+Alt, left, workspace, -1" | ||||
|           "$mod+Alt, right, workspace, +1" | ||||
|           "$mod, mouse_down, workspace, -1" | ||||
|           "$mod, mouse_up, workspace, +1" | ||||
|  | ||||
|           # move to scratch workspace | ||||
|           "$mod+Ctrl, up, movetoworkspace, special:magic" | ||||
|           "$mod+Ctrl, down, movetoworkspace, 1" | ||||
|           # toggle scratch workspace | ||||
|           "$mod+Alt, up, togglespecialworkspace, magic" | ||||
|           "$mod+Alt, down, togglespecialworkspace, magic" | ||||
|  | ||||
|           # Screenshot | ||||
|           "$mod, Print, exec, hyprshot -m region -o ~/Pictures/Screenshots" | ||||
|           "$mod+Shift, Print, exec, hyprshot -m window -o ~/Pictures/Screenshots" | ||||
|           # # somehow logitech calls this SUPER_L but we refer to it by its code | ||||
|           "SUPER_L&Shift_L, S, exec, hyprshot -m region -o ~/Pictures/Screenshots" | ||||
|           "Shift&SUPER_L&Shift_L, S, exec, hyprshot -m window -o ~/Pictures/Screenshots" | ||||
|           # when there is a dedicated screenshot button | ||||
|           ", XF86Cut, exec, hyprshot -m region -o ~/Pictures/Screenshots" | ||||
|           "Shift, XF86Cut, exec, hyprshot -m window -o ~/Pictures/Screenshots" | ||||
|  | ||||
|           # Power menu | ||||
|           ", XF86PowerOff, exec, ${lib.getExe config.nix-config.powerMenu}" | ||||
|  | ||||
|           # Other pickers using the same launcher | ||||
|           "$mod+Ctrl, space, exec, ${lib.getExe config.nix-config.filePicker}" | ||||
|  | ||||
|         ]; | ||||
|  | ||||
|         # repeatable bindings | ||||
|         binde = [ | ||||
|           # Fn keys | ||||
|           ", XF86MonBrightnessDown, exec, brightnessctl set 5%-" | ||||
|           ", XF86MonBrightnessUp, exec, brightnessctl set +5%" | ||||
|           ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+" | ||||
|           ", XF86AudioLowerVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%-" | ||||
|           ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" | ||||
|  | ||||
|           # Reshape the window in focus | ||||
|           "$mod, MINUS, resizeactive, -2% -2%" | ||||
|           "$mod, KP_Subtract, resizeactive, -2% -2%" | ||||
|           "$mod, PLUS, resizeactive, 2% 2%" | ||||
|           "$mod, KP_Add, resizeactive, 2% 2%" | ||||
|         ]; | ||||
|  | ||||
|         # lock-screen bindings | ||||
|         bindl = [ | ||||
|           ## depending on the setup: lock screen or switch to clamshell mode | ||||
|           # in any case, the internal screen is turned off | ||||
|           # ", switch:on:Lid Switch, exec, loginctl lock-session" | ||||
|  | ||||
|  | ||||
|           # if an additional monitor is detected, simply deactivate the internal screen and continue working on the external monitor | ||||
|           ", switch:on:Lid Switch, exec, hyprctl dispatch dpms off eDP-1" | ||||
|           ", switch:on:Lid Switch, exec, sleep 0.5; hyprctl monitors | grep 'dpmsStatus: 1' && hyprctl keyword monitor 'eDP-1,disable'" | ||||
|           # # if no external monitor is detected, lock the screen | ||||
|           # ", switch:on:Lid Switch, exec, sleep 0.5; hyprctl monitors | grep 'dpmsStatus: 1' || loginctl lock-session" | ||||
|  | ||||
|           ## on reopening the lid, turn the internal screen back on | ||||
|           ", switch:off:Lid Switch, exec, hyprctl dispatch dpms on eDP-1" | ||||
|           # if an external monitor was connected, then we need to reload the monitor configuration | ||||
|           ", switch:off:Lid Switch, exec, hyprctl monitors | grep 'ID 1' && hyprctl reload" | ||||
|         ]; | ||||
|  | ||||
|         # bindr = [ | ||||
|         #     # Overview | ||||
|         #   "$mod, , overview:toggle" | ||||
|         # ]; | ||||
|  | ||||
|         bindm = [ | ||||
|           # move the window using left click | ||||
|           "$mod, mouse:272, movewindow" | ||||
|           # resize the window using right click | ||||
|           "$mod, mouse:273, resizewindow" | ||||
|         ]; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										57
									
								
								modules/home-manager/hypr/hyprland/layouts.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								modules/home-manager/hypr/hyprland/layouts.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| {inputs, pkgs, lib, config, ...}: | ||||
| let | ||||
|   cfg = config.nix-config.hypr; | ||||
| in | ||||
| { | ||||
|   config = { | ||||
|     wayland.windowManager.hyprland = { | ||||
|       settings = { | ||||
|  | ||||
|         master = { | ||||
|           # TODO - I am not yet happy about the layout + toggle keybinds | ||||
|           orientation = "center"; | ||||
|           # equivalent toalways_center_master = true; | ||||
|           slave_count_for_center_master = 0; | ||||
|           # new_is_master = false; | ||||
|           # allow_small_split = true; | ||||
|           # special_scale_factor = 0.80; | ||||
|           mfact = 0.34; | ||||
|           inherit_fullscreen = false; | ||||
|           # always_center_master = false; | ||||
|           # allow a maximum of 3 windows in the master area for 3-column layout | ||||
|         }; | ||||
|  | ||||
|         #create special workspaces with no gaps | ||||
|         workspace = [ | ||||
|           "w[t1], gapsout:0, gapsin:0" | ||||
|           "w[tg1], gapsout:0, gapsin:0" | ||||
|           "f[1], gapsout:0, gapsin:0" | ||||
|         ]; | ||||
|  | ||||
|         # automatically assign windows to workspaces when there is only one window | ||||
|         windowrulev2 = [ | ||||
|           "bordersize 0, floating:0, onworkspace:w[t1]" | ||||
|           "rounding 0, floating:0, onworkspace:w[t1]" | ||||
|           "bordersize 0, floating:0, onworkspace:w[tg1]" | ||||
|           "rounding 0, floating:0, onworkspace:w[tg1]" | ||||
|           "bordersize 0, floating:0, onworkspace:f[1]" | ||||
|           "rounding 0, floating:0, onworkspace:f[1]" | ||||
|         ]; | ||||
|  | ||||
|         misc = { | ||||
|           vfr = false; | ||||
|           disable_hyprland_logo = true; | ||||
|         }; | ||||
|  | ||||
|         # Keybind to toggle between 2 and 3 column master layout | ||||
|         bind = [ | ||||
|           # Toggle master layout between 2 and 3 columns | ||||
|           "$mod, m, exec, hyprctl dispatch layoutmsg orientationleft" | ||||
|           "$mod, m, exec, hyprctl dispatch layoutmsg mfact exact 0.5" | ||||
|           # "SUPER_SHIFT,C,exec,hyprctl dispatch layoutmsg swap_master_count 2 3" | ||||
|         ]; | ||||
|  | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										20
									
								
								modules/home-manager/hypr/hyprland/packages.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								modules/home-manager/hypr/hyprland/packages.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| {inputs, pkgs, lib, config, ...}: | ||||
| let | ||||
|   cfg = config.nix-config.hypr; | ||||
| in | ||||
| { | ||||
|   # packages required by the current hyprland setup | ||||
|   home.packages = [ | ||||
|     pkgs.hyprshot | ||||
|     pkgs.nautilus | ||||
|     pkgs.gnome-control-center | ||||
|     pkgs.gnome-bluetooth # needed by gnome-control-center to manage bluetooth | ||||
|     pkgs.brightnessctl | ||||
|     pkgs.cliphist | ||||
|     pkgs.wl-clipboard | ||||
|     pkgs.gcr # Provides org.gnome.keyring.SystemPrompter | ||||
|   ]; | ||||
|  | ||||
|   # Also use gnome keyring | ||||
|   services.gnome-keyring.enable = true; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user