From 6015ed2634bce7298c60bc2067f965f3f78239c6 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Fri, 12 Apr 2024 11:52:31 +0200 Subject: [PATCH] use new hyprland nix --- common/hyprland.nix | 13 ++-- hosts/default/home.nix | 5 +- modules/hyprland.nix | 141 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 modules/hyprland.nix diff --git a/common/hyprland.nix b/common/hyprland.nix index 49638fe..fd1bebe 100644 --- a/common/hyprland.nix +++ b/common/hyprland.nix @@ -1,18 +1,16 @@ { config, pkgs, inputs, ... }: - +let + hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland; +in { # these are necessary for the config to function correctly imports = [ ./kitty.nix ./waybar.nix ./wofi.nix - # ./hypridle.nix # TODO: find out why these bitches not work - # ./hyprlock.nix ./dunst.nix ]; home.packages = with pkgs; [ - hyprland - # I always want these with hyprland anyways libnotify # to enable the notify-send command wl-clipboard @@ -24,9 +22,13 @@ playerctl ]; + + xdg.portal.configPackages = [ hyprland ]; + services.playerctld.enable = true; wayland.windowManager.hyprland = { enable = true; + package = hyprland; settings = { monitor = [ "DP-3,2560x1440@360,2560x0,1" @@ -122,5 +124,4 @@ ]; }; }; - } diff --git a/hosts/default/home.nix b/hosts/default/home.nix index 40b8b52..f98be27 100644 --- a/hosts/default/home.nix +++ b/hosts/default/home.nix @@ -5,7 +5,7 @@ [ inputs.nixvim.homeManagerModules.nixvim ../../common/zsh.nix - ../../common/hyprland.nix + ../../modules/hyprland.nix ../../common/git.nix ../../common/nvim/nvim.nix ../../common/discord/discord.nix @@ -29,6 +29,8 @@ nixpkgs.config.allowUnfree = true; + modules.hyprland.enable = true; + # The home.packages option allows you to install Nix packages into your # environment. home.packages = with pkgs; [ @@ -107,7 +109,6 @@ xdg.portal = { enable = true; extraPortals = [ pkgs.xdg-desktop-portal-hyprland ]; - configPackages = [ pkgs.hyprland ]; }; dconf = { diff --git a/modules/hyprland.nix b/modules/hyprland.nix new file mode 100644 index 0000000..310a8c9 --- /dev/null +++ b/modules/hyprland.nix @@ -0,0 +1,141 @@ +{ config, lib, pkgs, inputs, ... }: +let + hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland; + cfg = config.modules.hyprland; +in +{ + options = { + cfg.enable = lib.mkEnableOption "enable hyprland"; + # TODO: make custom terminal support work better + # cfg.terminal = lib.mkOption { + # type = lib.types.package; + # default = pkgs.kitty; + # description = "What terminal emulator should be used in hyprland"; + # }; + }; + + config = lib.mkIf cfg.enable { + # these are necessary for the config to function correctly + imports = [ + ./kitty.nix + ./waybar.nix + ./wofi.nix + ./dunst.nix + ]; + home.packages = with pkgs; [ + # I always want these with hyprland anyways + libnotify # to enable the notify-send command + wl-clipboard + + slurp + grim + + hypridle # TODO: remove when fixed with config + playerctl + ]; + + programs.waybar.enable = true; + + xdg.portal.configPackages = [ hyprland ]; + + services.playerctld.enable = true; + wayland.windowManager.hyprland = { + enable = true; + package = hyprland; + settings = { + monitor = [ + "DP-3,2560x1440@360,2560x0,1" + "DP-2,2560x1440@144,0x0,1" + ]; + windowrulev2 = [ + "opacity 1.0 0.6,class:^(kitty)$" + "stayfocused,class:^(wofi)$" + ]; + env = [ + "WLR_NO_HARDWARE_CURSORS,1" + ]; + exec-once = [ + "waybar" + "dunst" + "automapaper -C ${config.xdg.configHome}/automapaper/config.toml" + "automapaper -C ${config.xdg.configHome}/automapaper/config2nd.toml" + "hyprctl dispatcher focusmonitor 1" + "hypridle" + ]; + general = { + sensitivity = "1.2"; + gaps_in = "2"; + gaps_out = "3"; + border_size = "3"; + "col.active_border"="0xff950fad"; + "col.inactive_border"="0xff26052e"; + }; + misc = { + key_press_enables_dpms = true; + }; + decoration = { + rounding = "6"; + active_opacity = "1"; + inactive_opacity = "1"; + }; + workspace = [ + "DP-3,1" + "DP-2,2" + ]; + animations = { + enabled = "1"; + animation = [ + "windows,1,2,default" + "border,1,10,default" + "fade,0,5,default" + "workspaces,1,4,default" + ]; + }; + "$mod" = "SUPER"; + bind = [ + "$mod,Return,exec,${pkgs.kitty.pname}" + "$mod,tab,cyclenext" + "SUPERSHIFT,Q,killactive" + "$mod,SPACE,exec,wofi-launch" + "$mod,P,exec,wofi-power" + "SUPERSHIFT,m,exit" + "$mod,H,movefocus,l" + "$mod,J,movefocus,u" + "$mod,K,movefocus,d" + "$mod,L,movefocus,r" + "SUPERSHIFT,H,movewindow,l" + "SUPERSHIFT,J,movewindow,u" + "SUPERSHIFT,K,movewindow,d" + "SUPERSHIFT,L,movewindow,r" + "$mod,F,togglefloating" + "$mod,X,togglespecialworkspace" + "SUPERSHIFT,X,movetoworkspace,special" + "$mod,Print,exec,grim - | wl-copy && notify-send 'Screenshot Copied to Clipboard'" + "SUPERSHIFT,S,exec,slurp | grim -g - /tmp/photo && wl-copy < /tmp/photo && notify-send 'Screenshot Copied to Clipboard'" + "$mod,f11,fullscreen,0" + ",XF86AudioLowerVolume,exec,wpctl set-volume @DEFAULT_SINK@ 1%-" + ",XF86AudioRaiseVolume,exec,wpctl set-volume @DEFAULT_SINK@ 1%+" + ",XF86AudioMute,exec,wpctl set-mute @DEFAULT_SINK@ toggle" + ",XF86AudioPlay,exec,playerctl play-pause" + ",XF86AudioPrev,exec,playerctl previous" + ",XF86AudioNext,exec,playerctl next" + ] + ++ ( + builtins.concatLists (builtins.genList ( + x: let + ws = builtins.toString (x); + in [ + "$mod,${ws},workspace,${ws}" + "ALT,${ws},movetoworkspace,${ws}" + ] + ) + 10) + ); + bindm = [ + "$mod,mouse:272,movewindow" + "$mod,mouse:273,resizewindow" + ]; + }; + }; + }; +}