From 17eceb22539a784751bc1a3f7512dff835357fbc Mon Sep 17 00:00:00 2001 From: oddlama Date: Sun, 9 Jun 2024 16:50:23 +0200 Subject: [PATCH] feat: use correct portal for hyprland, add some hyprland keybinds --- config/graphical/default.nix | 10 +- users/myuser/graphical/hyprland.nix | 313 +++++++++++++++------------- users/myuser/graphical/theme.nix | 2 +- 3 files changed, 178 insertions(+), 147 deletions(-) diff --git a/config/graphical/default.nix b/config/graphical/default.nix index 056ca8d..c821d78 100644 --- a/config/graphical/default.nix +++ b/config/graphical/default.nix @@ -47,13 +47,15 @@ in enable = true; xdgOpenUsePortal = true; config.common = { - default = ["gtk"]; - "org.freedesktop.impl.portal.Secret" = [ - "gnome-keyring" - ]; + default = ["hyprland" "gtk"]; + "org.freedesktop.impl.portal.Secret" = ["gnome-keyring"]; + "org.freedesktop.impl.portal.ScreenCast" = ["hyprland"]; + "org.freedesktop.impl.portal.Screenshot" = ["hyprland"]; + "org.freedesktop.portal.FileChooser" = ["xdg-desktop-portal-gtk"]; }; extraPortals = [ pkgs.xdg-desktop-portal-hyprland + pkgs.xdg-desktop-portal-wlr pkgs.xdg-desktop-portal-gtk ]; }; diff --git a/users/myuser/graphical/hyprland.nix b/users/myuser/graphical/hyprland.nix index d7f4b22..49d49de 100644 --- a/users/myuser/graphical/hyprland.nix +++ b/users/myuser/graphical/hyprland.nix @@ -3,167 +3,196 @@ nixosConfig, pkgs, ... -}: { +}: let + inherit + (lib) + concatMap + elem + flip + getExe + mkIf + mkMerge + optionals + ; +in { home.packages = with pkgs; [ wl-clipboard ]; wayland.windowManager.hyprland = { enable = true; - settings = { - env = - lib.optionals (lib.elem "nvidia" nixosConfig.services.xserver.videoDrivers) [ - # See https://wiki.hyprland.org/Nvidia/ - "LIBVA_DRIVER_NAME,nvidia" - "XDG_SESSION_TYPE,wayland" - "GBM_BACKEND,nvidia-drm" - "__GLX_VENDOR_LIBRARY_NAME,nvidia" - ] - ++ [ - "NIXOS_OZONE_WL,1" - "MOZ_ENABLE_WAYLAND,1" - "MOZ_WEBRENDER,1" - "_JAVA_AWT_WM_NONREPARENTING,1" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "QT_QPA_PLATFORM,wayland" - "SDL_VIDEODRIVER,wayland" - "GDK_BACKEND,wayland" + settings = mkMerge [ + { + env = + optionals (elem "nvidia" nixosConfig.services.xserver.videoDrivers) [ + # See https://wiki.hyprland.org/Nvidia/ + "LIBVA_DRIVER_NAME,nvidia" + "XDG_SESSION_TYPE,wayland" + "GBM_BACKEND,nvidia-drm" + "__GLX_VENDOR_LIBRARY_NAME,nvidia" + ] + ++ [ + "NIXOS_OZONE_WL,1" + "MOZ_ENABLE_WAYLAND,1" + "MOZ_WEBRENDER,1" + "_JAVA_AWT_WM_NONREPARENTING,1" + "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" + "QT_QPA_PLATFORM,wayland" + "SDL_VIDEODRIVER,wayland" + "GDK_BACKEND,wayland" + ]; + + bind = + [ + "SUPER + CTRL + SHIFT,q,exit" + + # Applications + "SUPER,code:49,exec,${getExe pkgs.rofi-wayland} -show drun" # SUPER+^ + ",Menu,exec,${getExe pkgs.rofi-wayland} -show drun" + "SUPER,t,exec,kitty" + "SUPER,b,exec,firefox" + + # Shortcuts & Actions + #"SUPER + SHIFT,s,exec ${getExe pkgs.scripts.screenshot-area}" + #"SUPER,F11,exec ${getExe pkgs.scripts.screenshot-area-scan-qr}" + #"SUPER,F12,exec ${getExe pkgs.scripts.screenshot-screen}" + #"SUPER,Print,exec ${getExe pkgs.flameshot} gui" + + # Per-window actions + "SUPER,q,killactive," + "SUPER,return,fullscreen," + "SUPER,f,togglefloating" + + "SUPER,tab,cyclenext," + "ALT,tab,cyclenext," + "SUPER + SHIFT,tab,cyclenext,prev" + "ALT + SHIFT,tab,cyclenext,prev" + + "SUPER,left,movefocus,l" + "SUPER,right,movefocus,r" + "SUPER,up,movefocus,u" + "SUPER,down,movefocus,d" + + "SUPER + SHIFT,left,movewindow,l" + "SUPER + SHIFT,right,movewindow,r" + "SUPER + SHIFT,up,movewindow,u" + "SUPER + SHIFT,down,movewindow,d" + + "SUPER,comma,workspace,-1" + "SUPER,period,workspace,+1" + "SUPER + SHIFT,comma,movetoworkspacesilent,-1" + "SUPER + SHIFT,period,movetoworkspacesilent,+1" + ] + ++ flip concatMap (map toString (lib.lists.range 1 9)) ( + x: [ + "SUPER,${x},workspace,${x}" + "SUPER + SHIFT,${x},movetoworkspacesilent,${x}" + ] + ); + + bindm = [ + # mouse movements + "SUPER, mouse:272, movewindow" + "SUPER, mouse:273, resizewindow" + "SUPER ALT, mouse:272, resizewindow" ]; - bindm = [ - # mouse movements - "SUPER, mouse:272, movewindow" - "SUPER, mouse:273, resizewindow" - "SUPER ALT, mouse:272, resizewindow" - ]; - - animations = { - enabled = true; - animation = [ - "windows, 1, 4, default, slide" - "windowsOut, 1, 4, default, slide" - "windowsMove, 1, 4, default" - "border, 1, 2, default" - "fade, 1, 4, default" - "fadeDim, 1, 4, default" - "workspaces, 1, 4, default" - ]; - }; - - decoration.rounding = 4; - - # FIXME: TODO refactor and use mkmerge, this is ugly - monitor = - { - kroma = [ - "DP-2, preferred, 0x0, 1" - "DP-3, preferred, -3840x0, 1" - "Unknown-1, disable" + animations = { + enabled = true; + animation = [ + "windows, 1, 4, default, slide" + "windowsOut, 1, 4, default, slide" + "windowsMove, 1, 4, default" + "border, 1, 2, default" + "fade, 1, 4, default" + "fadeDim, 1, 4, default" + "workspaces, 1, 4, default" ]; - nom = [ - ]; - } - .${nixosConfig.node.name} - or []; - - workspace = - { - kroma = [ - "1, monitor:DP-2, default:true" - "2, monitor:DP-2" - "3, monitor:DP-2" - "4, monitor:DP-2" - "5, monitor:DP-2" - "6, monitor:DP-2" - "7, monitor:DP-3, default: true" - "8, monitor:DP-3" - "9, monitor:DP-3" - ]; - nom = [ - ]; - } - .${nixosConfig.node.name} - or []; - - cursor.no_warps = true; - - input = { - kb_layout = "de"; - follow_mouse = 2; - numlock_by_default = true; - repeat_rate = 60; - repeat_delay = 235; - # Only change focus on mouse click - float_switch_override_focus = 0; - accel_profile = "flat"; - - touchpad = { - natural_scroll = "no"; - disable_while_typing = true; - clickfinger_behavior = true; - scroll_factor = 0.7; }; - }; - general = { - gaps_in = 1; - gaps_out = 0; - allow_tearing = true; - }; + cursor.no_warps = true; + decoration.rounding = 4; - debug.disable_logs = false; + input = { + kb_layout = "de"; + follow_mouse = 2; + numlock_by_default = true; + repeat_rate = 60; + repeat_delay = 235; + # Only change focus on mouse click + float_switch_override_focus = 0; + accel_profile = "flat"; - misc = { - vfr = 1; - vrr = 1; - disable_hyprland_logo = true; - mouse_move_focuses_monitor = false; - }; - }; - extraConfig = - # TODO: env = WLR_DRM_NO_ATOMIC,1 - '' - windowrulev2 = immediate, class:^(cs2)$ + touchpad = { + natural_scroll = "no"; + disable_while_typing = true; + clickfinger_behavior = true; + scroll_factor = 0.7; + }; + }; - binds { - focus_preferred_method = 1 - } + general = { + gaps_in = 1; + gaps_out = 0; + allow_tearing = true; + }; - # keybinds - bind=SUPER,q,killactive, - bind=SUPER,return,fullscreen, - bind=SUPER,f,togglefloating - bind=SUPER,tab,cyclenext, - bind=ALT,tab,cyclenext, - bind=,Menu,exec,rofi -show drun + debug.disable_logs = false; - bind=SUPER,left,movefocus,l - bind=SUPER,right,movefocus,r - bind=SUPER,up,movefocus,u - bind=SUPER,down,movefocus,d + misc = { + vfr = 1; + vrr = 1; + disable_hyprland_logo = true; + mouse_move_focuses_monitor = false; + }; + } + (mkIf (nixosConfig.node.name == "kroma") { + monitor = [ + "DP-2, preferred, 0x0, 1" + "DP-3, preferred, -3840x0, 1" + # Thank you NVIDIA for this generous, free-of-charge, extra monitor that + # doesn't exist and crashes yoru session sometimes when moving a window to it. + "Unknown-1, disable" + ]; - bind=SUPER + SHIFT,left,movewindow,l - bind=SUPER + SHIFT,right,movewindow,r - bind=SUPER + SHIFT,up,movewindow,u - bind=SUPER + SHIFT,down,movewindow,d + windowrulev2 = [ + "workspace 1,class:^(firefox)$" + "workspace 5,class:^(bottles)$" + "workspace 5,class:^(steam)$" + "workspace 5,class:^(prismlauncher)$" + "workspace 7,class:^(discord)$" + "workspace 7,class:^(WebCord)$" + "workspace 7,class:^(obsidian)$" + "workspace 7,class:^(Signal)$" + "workspace 7,class:^(TelegramDesktop)$" + ]; - bindm=SUPER,mouse:272,movewindow + workspace = [ + "1, monitor:DP-2, default:true" + "2, monitor:DP-2" + "3, monitor:DP-2" + "4, monitor:DP-2" + "5, monitor:DP-2" + "6, monitor:DP-2" + "7, monitor:DP-3, default: true" + "8, monitor:DP-3" + "9, monitor:DP-3" + ]; + }) + (mkIf (nixosConfig.node.name == "nom") { + monitor = [ + ]; + workspace = [ + ]; + }) + ]; - bind=SUPER,comma,workspace,-1 - bind=SUPER,period,workspace,+1 + extraConfig = '' + windowrulev2 = immediate, class:^(cs2)$ - bind=SUPER,b,exec,firefox - bind=SUPER,t,exec,kitty - bind=SUPER + CTRL + SHIFT,q,exit - '' - + builtins.concatStringsSep "\n" ( - map ( - x: '' - bind=SUPER,${x},workspace,${x} - bind=SUPER + SHIFT,${x},movetoworkspacesilent,${x} - '' - ) - (map toString (lib.lists.range 1 9)) - ); + binds { + focus_preferred_method = 1 + } + ''; }; } diff --git a/users/myuser/graphical/theme.nix b/users/myuser/graphical/theme.nix index c597bc9..919a5dd 100644 --- a/users/myuser/graphical/theme.nix +++ b/users/myuser/graphical/theme.nix @@ -42,7 +42,7 @@ qt = { enable = true; style.name = "kvantum"; - platformTheme = "qtct"; + platformTheme.name = "qtct"; }; xdg.configFile."Kvantum/kvantum.kvconfig".text = "theme=Base16Kvantum";