{ pkgs, lib, config, ... }: let enabled = config.mod.hyprland.enable; in { options = { mod.hyprland = { enable = lib.mkEnableOption "enable hyprland module"; }; }; config = lib.mkIf enabled { home-manager.users.alex = { wayland.windowManager.hyprland = { enable = true; xwayland = { enable = true; }; extraConfig = '' exec-once=waybar exec-once=hyprctl setcursor Adwaita 24 env = GDK_DPI_SCALE,1.5 env = HYPRCURSOR_THEME,Adwaita env = HYPRCURSOR_SIZE,24 monitor=eDP-1, 1920x1200, auto-center-down, 1 monitor=HDMI-A-1, 2560x1440@100, auto-center-up, 1 workspace = 1, monitor:HDMI-A-1 workspace = 2, monitor:HDMI-A-1 workspace = 3, monitor:HDMI-A-1 workspace = 4, monitor:HDMI-A-1 workspace = 5, monitor:HDMI-A-1 workspace = 6, monitor:eDP-1 workspace = 7, monitor:eDP-1 workspace = 8, monitor:eDP-1 workspace = 9, monitor:eDP-1 workspace = 10, monitor:eDP-1 workspace = w[tv1], gapsout:0, gapsin:0 workspace = f[1], gapsout:0, gapsin:0 windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1] windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1] windowrulev2 = bordersize 0, floating:0, onworkspace:f[1] windowrulev2 = rounding 0, floating:0, onworkspace:f[1] exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP ''; settings = { "$mod" = "SUPER"; animations.enabled = false; xwayland = { force_zero_scaling = true; }; input = { kb_layout = "se"; # 2 - Cursor focus will be detached from keyboard focus. Clicking on a window will move keyboard focus to that window. follow_mouse = 2; sensitivity = 0.3; touchpad = { natural_scroll = false; tap-and-drag = false; }; }; cursor = { zoom_factor = 1; zoom_rigid = true; }; general = { layout = "dwindle"; gaps_in = 0; # gaps between windows gaps_out = 0; # gaps between windows and monitor edges "col.active_border" = "rgba(${config.lib.colors.foreground}ff)"; "col.inactive_border" = "rgba(${config.lib.colors.background}ff)"; }; dwindle = { force_split = 2; }; bind = let ws = x: let n = if (x + 1) < 10 then (x + 1) else 0; in builtins.toString n; select = builtins.genList (x: "$mod, ${ws x}, workspace, ${builtins.toString (x + 1)}") 10; move = builtins.genList ( x: "$mod SHIFT, ${ws x}, movetoworkspacesilent, ${builtins.toString (x + 1)}" ) 10; magnifier = pkgs.writeShellScript "magnifier" '' CURRENT=$(${pkgs.hyprland}/bin/hyprctl getoption cursor:zoom_factor -j | ${pkgs.jq}/bin/jq .float) DELTA=0.1 UPDATED=1 case $1 in --increase) UPDATED=$(echo $CURRENT + $DELTA | ${pkgs.bc}/bin/bc) ;; --decrease) UPDATED=$(echo $CURRENT - $DELTA | ${pkgs.bc}/bin/bc) ;; --reset) UPDATED=1 esac if (( $(echo "$UPDATED < 1" | bc) )); then UPDATED=1; fi ${pkgs.hyprland}/bin/hyprctl keyword cursor:zoom_factor $UPDATED ''; in select ++ move ++ [ "$mod, ESCAPE, killactive" "$mod, f, fullscreen, 1" "$mod SHIFT, f, togglefloating, active" "$mod, h, movefocus, l" "$mod, j, movefocus, d" "$mod, k, movefocus, u" "$mod, l, movefocus, r" "$mod CONTROL, 1, exec, ${magnifier} --increase" "$mod CONTROL, 2, exec, ${magnifier} --decrease" "$mod CONTROL, 3, exec, ${magnifier} --reset" ]; bindm = [ # mouse movements "$mod, mouse:272, movewindow" # left click "$mod, mouse:273, resizewindow" # right click ]; misc = { disable_hyprland_logo = true; disable_splash_rendering = true; }; }; }; home.packages = [ pkgs.wdisplays pkgs.bc ]; }; # To start electron apps like `chromium` with wayland support environment.sessionVariables.NIXOS_OZONE_WL = "1"; # The XDG portal is needed for screen sharing xdg.portal = { enable = true; # override "trace: warning: xdg-desktop-portal 1.17 reworked how portal implementations are loaded ..." config.common.default = "*"; extraPortals = [ pkgs.xdg-desktop-portal-wlr ]; }; # openGL is needed for wayland/hyprland hardware.graphics.enable = true; }; }