From 284f242e7287986ea4d21a93517dde462d7efc07 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Thu, 4 Jan 2024 22:14:17 -0300 Subject: [PATCH] feat: add hyprfocus hyprland plugin --- flake.lock | 37 ++++ flake.nix | 18 +- programs/hyprland/config.nix | 305 +++++++++++++++++++++++++++++++- programs/hyprland/hyprland.conf | 262 --------------------------- 4 files changed, 347 insertions(+), 275 deletions(-) delete mode 100644 programs/hyprland/hyprland.conf diff --git a/flake.lock b/flake.lock index 8055430..ea26454 100644 --- a/flake.lock +++ b/flake.lock @@ -44,6 +44,27 @@ "type": "github" } }, + "hyprland-hyprfocus": { + "inputs": { + "hyprland": [ + "hyprland" + ], + "nix-filter": "nix-filter" + }, + "locked": { + "lastModified": 1698854678, + "narHash": "sha256-JuUNQXUetKIUGGwzEA5dQmKtpFvYSZzG/IV373aKd6U=", + "owner": "VortexCoyote", + "repo": "hyprfocus", + "rev": "ec3b45482f651c2b1f0e4df90a41d24a1afa5a74", + "type": "github" + }, + "original": { + "owner": "VortexCoyote", + "repo": "hyprfocus", + "type": "github" + } + }, "hyprland-protocols": { "inputs": { "nixpkgs": [ @@ -69,6 +90,21 @@ "type": "github" } }, + "nix-filter": { + "locked": { + "lastModified": 1694857738, + "narHash": "sha256-bxxNyLHjhu0N8T3REINXQ2ZkJco0ABFPn6PIe2QUfqo=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "41fd48e00c22b4ced525af521ead8792402de0ea", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1703637592, @@ -89,6 +125,7 @@ "inputs": { "home-manager": "home-manager", "hyprland": "hyprland", + "hyprland-hyprfocus": "hyprland-hyprfocus", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index 3c95774..c3386da 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,11 @@ url = "github:hyprwm/Hyprland"; inputs.nixpkgs.follows = "nixpkgs"; }; + + hyprland-hyprfocus = { + url = "github:VortexCoyote/hyprfocus"; + inputs.hyprland.follows = "hyprland"; + }; }; outputs = { @@ -20,6 +25,7 @@ nixpkgs, home-manager, hyprland, + hyprland-hyprfocus, ... }@inputs: { nixosConfigurations.nixos = @@ -38,21 +44,11 @@ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = inputs; home-manager.users.wizardlink = import ./home-manager.nix; } ]; in nixpkgs.lib.nixosSystem { inherit system modules; }; - - homeConfigurations."wizardlink@nixos" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - - modules = [ - hyprland.homeManagerModules.default - { - wayland.windowManager.hyprland.enable = true; - } - ]; - }; }; } diff --git a/programs/hyprland/config.nix b/programs/hyprland/config.nix index 897997e..063dd67 100644 --- a/programs/hyprland/config.nix +++ b/programs/hyprland/config.nix @@ -1,8 +1,309 @@ -{ ... }: +{ pkgs, hyprland, hyprland-hyprfocus, ... }: { + imports = [ hyprland.homeManagerModules.default ]; + wayland.windowManager.hyprland = { enable = true; - extraConfig = builtins.readFile ./hyprland.conf; + + plugins = [ + hyprland-hyprfocus.packages.${pkgs.system}.hyprfocus + ]; + + extraConfig = '' + + ######################################################################################## + AUTOGENERATED HYPR CONFIG. + PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT, + OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS. + ######################################################################################## + + # Catppuccin Macchiato - https://github.com/catppuccin/hyprland + $rosewaterAlpha = f4dbd6 + $flamingoAlpha = f0c6c6 + $pinkAlpha = f5bde6 + $mauveAlpha = c6a0f6 + $redAlpha = ed8796 + $maroonAlpha = ee99a0 + $peachAlpha = f5a97f + $yellowAlpha = eed49f + $greenAlpha = a6da95 + $tealAlpha = 8bd5ca + $skyAlpha = 91d7e3 + $sapphireAlpha = 7dc4e4 + $blueAlpha = 8aadf4 + $lavenderAlpha = b7bdf8 + + $textAlpha = cad3f5 + $subtext1Alpha = b8c0e0 + $subtext0Alpha = a5adcb + + $overlay2Alpha = 939ab7 + $overlay1Alpha = 8087a2 + $overlay0Alpha = 6e738d + + $surface2Alpha = 5b6078 + $surface1Alpha = 494d64 + $surface0Alpha = 363a4f + + $baseAlpha = 24273a + $mantleAlpha = 1e2030 + $crustAlpha = 181926 + + $rosewater = 0xfff5e0dc + $flamingo = 0xfff2cdcd + $pink = 0xfff5c2e7 + $mauve = 0xffcba6f7 + $red = 0xfff38ba8 + $maroon = 0xffeba0ac + $peach = 0xfffab387 + $yellow = 0xfff9e2af + $green = 0xffa6e3a1 + $teal = 0xff94e2d5 + $sky = 0xff89dceb + $sapphire = 0xff74c7ec + $blue = 0xff89b4fa + $lavender = 0xffb4befe + + $text = 0xffcdd6f4 + $subtext1 = 0xffbac2de + $subtext0 = 0xffa6adc8 + + $overlay2 = 0xff9399b2 + $overlay1 = 0xff7f849c + $overlay0 = 0xff6c7086 + + $surface2 = 0xff585b70 + $surface1 = 0xff45475a + $surface0 = 0xff313244 + + $base = 0xff1e1e2e + $mantle = 0xff181825 + $crust = 0xff11111b + + # + # Please note not all available settings / options are set here. + # For a full list, see the wiki + # + + autogenerated = 0 # remove this line to remove the warning + + # See https://wiki.hyprland.org/Configuring/Monitors/ + monitor = DP-3, 1920x1080@75, 2560x0, 1 + monitor = DP-2, 2560x1440@165, 0x0, 1 + + # See https://wiki.hyprland.org/Configuring/Keywords/ for more + + # Execute your favorite apps at launch + exec-once = ~/.local/share/scripts/hyprland/start_services.sh + + # Source a file (multi-file configs) + # source = ~/.config/hypr/myColors.conf + + # Some default env vars. + env = XCURSOR_SIZE,36 + env = QT_QPA_PLATFORM,wayland + + # For all categories, see https://wiki.hyprland.org/Configuring/Variables/ + input { + kb_layout = us,br + kb_variant = + kb_model = + kb_options = + kb_rules = + + follow_mouse = 1 + float_switch_override_focus = 1 + + accel_profile = flat + force_no_accel = true + + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. + } + + device:wacom-bamboo-one-m-pen { + output = DP-2 + } + + general { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + + gaps_in = 5 + gaps_out = 20 + border_size = 0 # Removed because of hyprfocus plugin + col.active_border = $lavender + col.inactive_border = $crust + + layout = dwindle + } + + decoration { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + + rounding = 8 + # FIXME: Check these deprecations. + #blur = yes + #blur_size = 3 + #blur_passes = 1 + #blur_new_optimizations = on + + drop_shadow = yes + shadow_range = 4 + shadow_render_power = 3 + col.shadow = $crust + } + + animations { + enabled = yes + + # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more + + bezier = myBezier, 0.05, 0.9, 0.1, 1.05 + + animation = windows, 1, 7, myBezier + animation = windowsOut, 1, 7, default, popin 80% + animation = border, 1, 10, default + animation = borderangle, 1, 8, default + animation = fade, 1, 7, default + animation = workspaces, 1, 6, default + } + + dwindle { + # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more + pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = yes # you probably want this + } + + master { + # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more + new_is_master = true + } + + gestures { + # See https://wiki.hyprland.org/Configuring/Variables/ for more + workspace_swipe = off + } + + # Example per-device config + # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more + device:epic-mouse-v1 { + sensitivity = -0.5 + } + + # Example windowrule v1 + # windowrule = float, ^(kitty)$ + # Example windowrule v2 + # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ + # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more + + # Bind workspaces to specific monitors + workspace = 1, monitor:DP-2 + workspace = 2, monitor:DP-3 + workspace = 3, monitor:DP-2 + workspace = 4, monitor:DP-3 + workspace = 5, monitor:DP-2 + workspace = 6, monitor:DP-3 + workspace = 7, monitor:DP-2 + workspace = 8, monitor:DP-3 + workspace = 9, monitor:DP-2 + workspace = 0, monitor:DP-3 + + # See https://wiki.hyprland.org/Configuring/Keywords/ for more + $mainMod = SUPER + + # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more + bind = $mainMod CTRL, F, fakefullscreen + bind = $mainMod CTRL, K, exec, hyprctl switchxkblayout ducky-ducky-one2-mini-rgb next + bind = $mainMod CTRL, L, exec, cliphist list | rofi -dmenu | cliphist decode | wl-copy + bind = $mainMod CTRL, P, exec, ~/.local/share/scripts/hyprland/screenshot_area.sh + bind = $mainMod CTRL, V, pin + bind = $mainMod SHIFT, F, fullscreen, 1 + bind = $mainMod SHIFT, P, exec, ~/.local/share/scripts/hyprland/screenshot.sh + bind = $mainMod, C, killactive + bind = $mainMod, E, exec, dolphin + bind = $mainMod, F, fullscreen + bind = $mainMod, M, exit + bind = $mainMod, O, togglesplit # dwindle + bind = $mainMod, P, pseudo # dwindle + bind = $mainMod, Q, exec, wezterm + bind = $mainMod, R, exec, rofi -show drun + bind = $mainMod, V, togglefloating + + # Move focus with mainMod + arrow keys + bind = $mainMod, H, movefocus, l + bind = $mainMod, L, movefocus, r + bind = $mainMod, K, movefocus, u + bind = $mainMod, J, movefocus, d + + # Switch workspaces with mainMod + [0-9] + bind = $mainMod, 1, workspace, 1 + bind = $mainMod, 2, workspace, 2 + bind = $mainMod, 3, workspace, 3 + bind = $mainMod, 4, workspace, 4 + bind = $mainMod, 5, workspace, 5 + bind = $mainMod, 6, workspace, 6 + bind = $mainMod, 7, workspace, 7 + bind = $mainMod, 8, workspace, 8 + #bind = $mainMod, 9, workspace, 9 + #bind = $mainMod, 0, workspace, 10 + + # Move active window to a workspace with mainMod + SHIFT + [0-9] + bind = $mainMod SHIFT, 1, movetoworkspace, 1 + bind = $mainMod SHIFT, 2, movetoworkspace, 2 + bind = $mainMod SHIFT, 3, movetoworkspace, 3 + bind = $mainMod SHIFT, 4, movetoworkspace, 4 + bind = $mainMod SHIFT, 5, movetoworkspace, 5 + bind = $mainMod SHIFT, 6, movetoworkspace, 6 + bind = $mainMod SHIFT, 7, movetoworkspace, 7 + bind = $mainMod SHIFT, 8, movetoworkspace, 8 + bind = $mainMod SHIFT, 9, movetoworkspace, 9 + bind = $mainMod SHIFT, 0, movetoworkspace, 10 + + # Scroll through existing workspaces with mainMod + scroll + bind = $mainMod, mouse_down, workspace, e+1 + bind = $mainMod, mouse_up, workspace, e-1 + + # Move/resize windows with mainMod + LMB/RMB and dragging + bind = $mainMod SHIFT, H, movewindow, l + bind = $mainMod SHIFT, L, movewindow, r + bind = $mainMod SHIFT, K, movewindow, u + bind = $mainMod SHIFT, J, movewindow, d + bindm = $mainMod, mouse:272, movewindow + bindm = $mainMod, mouse:273, resizewindow + + # Window rules + windowrulev2 = float,class:(steam) # Make sure all Steam windows float + + # Plugins + plugin:hyprfocus { + enabled = yes + + keyboard_focus_animation = shrink + mouse_focus_animation = shrink + + bezier = bezIn, 0.5,0.0,1.0,0.5 + bezier = bezOut, 0.0,0.5,0.5,1.0 + + flash { + flash_opacity = 0.7 + + in_bezier = bezIn + in_speed = 0.5 + + out_bezier = bezOut + out_speed = 3 + } + + shrink { + shrink_percentage = 0.99 + + in_bezier = bezIn + in_speed = 1.5 + + out_bezier = bezOut + out_speed = 2.5 + } + } + ''; }; } diff --git a/programs/hyprland/hyprland.conf b/programs/hyprland/hyprland.conf deleted file mode 100644 index 1f1577b..0000000 --- a/programs/hyprland/hyprland.conf +++ /dev/null @@ -1,262 +0,0 @@ - -######################################################################################## -AUTOGENERATED HYPR CONFIG. -PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT, -OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS. -######################################################################################## - -# Catppuccin Macchiato - https://github.com/catppuccin/hyprland -$rosewaterAlpha = f4dbd6 -$flamingoAlpha = f0c6c6 -$pinkAlpha = f5bde6 -$mauveAlpha = c6a0f6 -$redAlpha = ed8796 -$maroonAlpha = ee99a0 -$peachAlpha = f5a97f -$yellowAlpha = eed49f -$greenAlpha = a6da95 -$tealAlpha = 8bd5ca -$skyAlpha = 91d7e3 -$sapphireAlpha = 7dc4e4 -$blueAlpha = 8aadf4 -$lavenderAlpha = b7bdf8 - -$textAlpha = cad3f5 -$subtext1Alpha = b8c0e0 -$subtext0Alpha = a5adcb - -$overlay2Alpha = 939ab7 -$overlay1Alpha = 8087a2 -$overlay0Alpha = 6e738d - -$surface2Alpha = 5b6078 -$surface1Alpha = 494d64 -$surface0Alpha = 363a4f - -$baseAlpha = 24273a -$mantleAlpha = 1e2030 -$crustAlpha = 181926 - -$rosewater = 0xfff5e0dc -$flamingo = 0xfff2cdcd -$pink = 0xfff5c2e7 -$mauve = 0xffcba6f7 -$red = 0xfff38ba8 -$maroon = 0xffeba0ac -$peach = 0xfffab387 -$yellow = 0xfff9e2af -$green = 0xffa6e3a1 -$teal = 0xff94e2d5 -$sky = 0xff89dceb -$sapphire = 0xff74c7ec -$blue = 0xff89b4fa -$lavender = 0xffb4befe - -$text = 0xffcdd6f4 -$subtext1 = 0xffbac2de -$subtext0 = 0xffa6adc8 - -$overlay2 = 0xff9399b2 -$overlay1 = 0xff7f849c -$overlay0 = 0xff6c7086 - -$surface2 = 0xff585b70 -$surface1 = 0xff45475a -$surface0 = 0xff313244 - -$base = 0xff1e1e2e -$mantle = 0xff181825 -$crust = 0xff11111b - -# -# Please note not all available settings / options are set here. -# For a full list, see the wiki -# - -autogenerated = 0 # remove this line to remove the warning - -# See https://wiki.hyprland.org/Configuring/Monitors/ -monitor = DP-3, 1920x1080@75, 2560x0, 1 -monitor = DP-2, 2560x1440@165, 0x0, 1 - -# See https://wiki.hyprland.org/Configuring/Keywords/ for more - -# Execute your favorite apps at launch -exec-once = ~/.local/share/scripts/hyprland/start_services.sh - -# Source a file (multi-file configs) -# source = ~/.config/hypr/myColors.conf - -# Some default env vars. -env = XCURSOR_SIZE,36 -env = QT_QPA_PLATFORM,wayland - -# For all categories, see https://wiki.hyprland.org/Configuring/Variables/ -input { - kb_layout = us,br - kb_variant = - kb_model = - kb_options = - kb_rules = - - follow_mouse = 1 - float_switch_override_focus = 1 - - accel_profile = flat - force_no_accel = true - - sensitivity = 0 # -1.0 - 1.0, 0 means no modification. -} - -device:wacom-bamboo-one-m-pen { - output = DP-2 -} - -general { - # See https://wiki.hyprland.org/Configuring/Variables/ for more - - gaps_in = 5 - gaps_out = 20 - border_size = 2 - col.active_border = $lavender - col.inactive_border = $crust - - layout = dwindle -} - -decoration { - # See https://wiki.hyprland.org/Configuring/Variables/ for more - - rounding = 8 - # FIXME: Check these deprecations. - #blur = yes - #blur_size = 3 - #blur_passes = 1 - #blur_new_optimizations = on - - drop_shadow = yes - shadow_range = 4 - shadow_render_power = 3 - col.shadow = rgba(1a1a1aee) -} - -animations { - enabled = yes - - # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more - - bezier = myBezier, 0.05, 0.9, 0.1, 1.05 - - animation = windows, 1, 7, myBezier - animation = windowsOut, 1, 7, default, popin 80% - animation = border, 1, 10, default - animation = borderangle, 1, 8, default - animation = fade, 1, 7, default - animation = workspaces, 1, 6, default -} - -dwindle { - # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more - pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below - preserve_split = yes # you probably want this -} - -master { - # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more - new_is_master = true -} - -gestures { - # See https://wiki.hyprland.org/Configuring/Variables/ for more - workspace_swipe = off -} - -# Example per-device config -# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more -device:epic-mouse-v1 { - sensitivity = -0.5 -} - -# Example windowrule v1 -# windowrule = float, ^(kitty)$ -# Example windowrule v2 -# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ -# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more - -# Bind workspaces to specific monitors -workspace = 1, monitor:DP-2 -workspace = 2, monitor:DP-3 -workspace = 3, monitor:DP-2 -workspace = 4, monitor:DP-3 -workspace = 5, monitor:DP-2 -workspace = 6, monitor:DP-3 -workspace = 7, monitor:DP-2 -workspace = 8, monitor:DP-3 -workspace = 9, monitor:DP-2 -workspace = 0, monitor:DP-3 - -# See https://wiki.hyprland.org/Configuring/Keywords/ for more -$mainMod = SUPER - -# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more -bind = $mainMod CTRL, F, fakefullscreen -bind = $mainMod CTRL, K, exec, hyprctl switchxkblayout ducky-ducky-one2-mini-rgb next -bind = $mainMod CTRL, L, exec, cliphist list | rofi -dmenu | cliphist decode | wl-copy -bind = $mainMod CTRL, P, exec, ~/.local/share/scripts/hyprland/screenshot_area.sh -bind = $mainMod CTRL, V, pin -bind = $mainMod SHIFT, F, fullscreen, 1 -bind = $mainMod SHIFT, P, exec, ~/.local/share/scripts/hyprland/screenshot.sh -bind = $mainMod, C, killactive -bind = $mainMod, E, exec, dolphin -bind = $mainMod, F, fullscreen -bind = $mainMod, M, exit -bind = $mainMod, O, togglesplit # dwindle -bind = $mainMod, P, pseudo # dwindle -bind = $mainMod, Q, exec, wezterm -bind = $mainMod, R, exec, rofi -show drun -bind = $mainMod, V, togglefloating - -# Move focus with mainMod + arrow keys -bind = $mainMod, H, movefocus, l -bind = $mainMod, L, movefocus, r -bind = $mainMod, K, movefocus, u -bind = $mainMod, J, movefocus, d - -# Switch workspaces with mainMod + [0-9] -bind = $mainMod, 1, workspace, 1 -bind = $mainMod, 2, workspace, 2 -bind = $mainMod, 3, workspace, 3 -bind = $mainMod, 4, workspace, 4 -bind = $mainMod, 5, workspace, 5 -bind = $mainMod, 6, workspace, 6 -bind = $mainMod, 7, workspace, 7 -bind = $mainMod, 8, workspace, 8 -#bind = $mainMod, 9, workspace, 9 -#bind = $mainMod, 0, workspace, 10 - -# Move active window to a workspace with mainMod + SHIFT + [0-9] -bind = $mainMod SHIFT, 1, movetoworkspace, 1 -bind = $mainMod SHIFT, 2, movetoworkspace, 2 -bind = $mainMod SHIFT, 3, movetoworkspace, 3 -bind = $mainMod SHIFT, 4, movetoworkspace, 4 -bind = $mainMod SHIFT, 5, movetoworkspace, 5 -bind = $mainMod SHIFT, 6, movetoworkspace, 6 -bind = $mainMod SHIFT, 7, movetoworkspace, 7 -bind = $mainMod SHIFT, 8, movetoworkspace, 8 -bind = $mainMod SHIFT, 9, movetoworkspace, 9 -bind = $mainMod SHIFT, 0, movetoworkspace, 10 - -# Scroll through existing workspaces with mainMod + scroll -bind = $mainMod, mouse_down, workspace, e+1 -bind = $mainMod, mouse_up, workspace, e-1 - -# Move/resize windows with mainMod + LMB/RMB and dragging -bind = $mainMod SHIFT, H, movewindow, l -bind = $mainMod SHIFT, L, movewindow, r -bind = $mainMod SHIFT, K, movewindow, u -bind = $mainMod SHIFT, J, movewindow, d -bindm = $mainMod, mouse:272, movewindow -bindm = $mainMod, mouse:273, resizewindow - -# Window rules -windowrulev2 = float,class:(steam) # Make sure all Steam windows float