From b36b3abf53797ceeaa348c3ad1cac864fafa105c Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Fri, 13 Dec 2024 14:52:31 +0100 Subject: [PATCH] home/programs/hypr: add basic hyprland configuration --- home/programs/hypr/default.nix | 7 +++ home/programs/hypr/idle.nix | 30 +++++++++++ home/programs/hypr/land/binds.nix | 61 ++++++++++++++++++++++ home/programs/hypr/land/default.nix | 79 +++++++++++++++++++++++++++++ home/programs/hypr/lock.nix | 35 +++++++++++++ 5 files changed, 212 insertions(+) create mode 100644 home/programs/hypr/default.nix create mode 100644 home/programs/hypr/idle.nix create mode 100644 home/programs/hypr/land/binds.nix create mode 100644 home/programs/hypr/land/default.nix create mode 100644 home/programs/hypr/lock.nix diff --git a/home/programs/hypr/default.nix b/home/programs/hypr/default.nix new file mode 100644 index 0000000..da93cc1 --- /dev/null +++ b/home/programs/hypr/default.nix @@ -0,0 +1,7 @@ +_: { + imports = [ + ./land + ./idle.nix + ./lock.nix + ]; +} diff --git a/home/programs/hypr/idle.nix b/home/programs/hypr/idle.nix new file mode 100644 index 0000000..c3f72ac --- /dev/null +++ b/home/programs/hypr/idle.nix @@ -0,0 +1,30 @@ +_: { + services.hypridle = { + enable = true; + + settings = { + general = { + lock_cmd = "pidof hyprlock || hyprlock"; + unlock_cmd = "pkill --signal SIGUSR1 hyprlock"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + }; + + listener = [ + { + timeout = 300; # 5m + on-timeout = "loginctl lock-session"; + } + { + timeout = 330; # 5.5m + on-timeout = "hyprctl dipsatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + { + timeout = 600; # 10m + on-timeout = "systemctl suspend"; + } + ]; + }; + }; +} diff --git a/home/programs/hypr/land/binds.nix b/home/programs/hypr/land/binds.nix new file mode 100644 index 0000000..98482d8 --- /dev/null +++ b/home/programs/hypr/land/binds.nix @@ -0,0 +1,61 @@ +_: { + wayland.windowManager.hyprland.settings = { + "$mod" = "SUPER"; + bind = [ + "$mod, Return, exec, foot" + "$mod, w, exec, firefox" + ", Print, exec, grimblast --notify copy output" + "$mod, q, killactive" + "$mod SHIFT, q, exit" + "$mod, Space, exec, fuzzel" + "CTRL, Print, exec, grimblast --notify --freeze copy area" + + "$mod, h, movefocus, l" + "$mod, j, movefocus, d" + "$mod, k, movefocus, u" + "$mod, l, movefocus, r" + + "$mod SHIFT, h, movewindow, l" + "$mod SHIFT, j, movewindow, d" + "$mod SHIFT, k, movewindow, u" + "$mod SHIFT, l, movewindow, r" + + "$mod, 1, workspace, 1" + "$mod, 2, workspace, 2" + "$mod, 3, workspace, 3" + "$mod, 4, workspace, 4" + "$mod, 5, workspace, 5" + "$mod, 6, workspace, 6" + "$mod, 7, workspace, 7" + "$mod, 8, workspace, 8" + "$mod, 9, workspace, 9" + "$mod, 0, workspace, 10" + + "$mod SHIFT, 1, movetoworkspacesilent, 1" + "$mod SHIFT, 2, movetoworkspacesilent, 2" + "$mod SHIFT, 3, movetoworkspacesilent, 3" + "$mod SHIFT, 4, movetoworkspacesilent, 4" + "$mod SHIFT, 5, movetoworkspacesilent, 5" + "$mod SHIFT, 6, movetoworkspacesilent, 6" + "$mod SHIFT, 7, movetoworkspacesilent, 7" + "$mod SHIFT, 8, movetoworkspacesilent, 8" + "$mod SHIFT, 9, movetoworkspacesilent, 9" + "$mod SHIFT, 0, movetoworkspacesilent, 10" + + "$mod, t, togglefloating" + ", F11, fullscreen, 0" + "$mod, f, fullscreen, 1" + + "$mod, e, togglespecialworkspace, file_manager_tui" + "$mod SHIFT, e, togglespecialworkspace, file_manager_gui" + ]; + + binde = [ + ", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+" + ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" + + ", XF86MonBrightnessUp, exec, brightnessctl set 2%+" + ", XF86MonBrightnessDown, exec, brightnessctl set 2%- -n" + ]; + }; +} diff --git a/home/programs/hypr/land/default.nix b/home/programs/hypr/land/default.nix new file mode 100644 index 0000000..8c38118 --- /dev/null +++ b/home/programs/hypr/land/default.nix @@ -0,0 +1,79 @@ +{ + inputs, + pkgs, + ... +}: { + imports = [./binds.nix]; + home.packages = [ + inputs.hyprwm-contrib.packages.${pkgs.system}.grimblast + ]; + wayland.windowManager.hyprland = { + enable = true; + xwayland.enable = true; + systemd = { + enable = true; + variables = ["--all"]; + }; + + settings = { + workspace = [ + "special:terminal, on-created-empty:foot" + "special:mixer_gui, on-created-empty:pavucontrol" + "special:file_manager_gui, on-created-empty:nautilus" + "special:file_manager_tui, on-created-empty:foot -- yazi" + ]; + + windowrulev2 = [ + # fixes fullscreen windows (mostly games) + "stayfocused, initialtitle:^()$, initialclass:^(steam)$" + "minsize 1 1, initialtitle:^()$, initialclass:^(steam)$" + "maximize, initialtitle:^(\S+)$, initialclass:^(steamwebhelper)$" + + "immediate, initialclass:^(steam_app_)(.*)$" + "fullscreen, initialclass:^(steam_app_)(.*)$" + ]; + + render = { + explicit_sync = 1; + explicit_sync_kms = 1; + expand_undersized_textures = false; + }; + + animations = { + enabled = true; + bezier = "myBezier, 0.05, 0.9, 0.1, 1.1"; + animation = [ + "windows, 1, 5, myBezier" + "windowsOut, 1, 5, default, popin 80%" + "windowsMove, 1, 5, default, popin 80%" + "fade, 1, 5, default" + "border, 1, 5, default" + "borderangle, 0, 8, default" + "workspaces, 0" + "specialWorkspace, 0" + ]; + }; + + input = { + kb_options = "compose:ralt"; + touchpad = { + natural_scroll = true; + scroll_factor = 0.8; + tap-to-click = false; + }; + }; + + gestures = { + workspace_swipe = true; + workspace_swipe_direction_lock = false; + workspace_swipe_cancel_ratio = 0.15; + }; + + misc = { + force_default_wallpaper = 0; + disable_hyprland_logo = true; + middle_click_paste = false; + }; + }; + }; +} diff --git a/home/programs/hypr/lock.nix b/home/programs/hypr/lock.nix new file mode 100644 index 0000000..d857801 --- /dev/null +++ b/home/programs/hypr/lock.nix @@ -0,0 +1,35 @@ +_: { + programs.hyprlock = { + enable = true; + settings = { + general = { + disable_loading_bar = true; + hide_cursor = true; + no_fade_in = false; + }; + + background = [ + { + path = "screenshot"; + blur_passes = 3; + blur_size = 8; + } + ]; + + input-field = [ + { + size = "200, 50"; + position = "0, -80"; + monitor = ""; + dots_center = true; + fade_on_empty = false; + font_color = "rgb(202, 211, 245)"; + inner_color = "rgb(91, 96, 120)"; + outer_color = "rgb(24, 25, 38)"; + outline_thickness = 5; + shadow_passes = 2; + } + ]; + }; + }; +}