From cd6d62efc5580243f63042aaef1af8e4ae4b90f2 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 25 Nov 2023 19:24:33 -0500 Subject: [PATCH] feat(greetd): add option to only show on main monitor --- common/device-vars.nix | 16 ++++++++++++++++ devices/binto/default.nix | 2 ++ modules/greetd/default.nix | 37 ++++++++++++++++++++++++++---------- modules/greetd/hyprland.conf | 10 ++++++++++ 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/common/device-vars.nix b/common/device-vars.nix index 5f171c9..5a20d69 100644 --- a/common/device-vars.nix +++ b/common/device-vars.nix @@ -14,6 +14,22 @@ type = types.nullOr types.str; }; + mainMonitor = mkOption { + description = '' + The name of the main monitor used for Hyprland and Regreet + ''; + default = "null"; + type = types.nullOr types.str; + }; + + greetdDupe = mkOption { + description = '' + If we should duplicate regreet on all monitors + ''; + default = true; + type = types.nullOr types.bool; + }; + fontSize = mkOption { type = types.nullOr types.float; }; diff --git a/devices/binto/default.nix b/devices/binto/default.nix index ff7b066..ddc0b53 100644 --- a/devices/binto/default.nix +++ b/devices/binto/default.nix @@ -18,6 +18,8 @@ services.device-vars = { username = "matt"; configDir = "/home/matt/.nix/devices/binto/config"; + mainMonitor = "DP-5"; + greetdDupe = false; fontSize = 12.5; }; diff --git a/modules/greetd/default.nix b/modules/greetd/default.nix index 38d8385..b183210 100644 --- a/modules/greetd/default.nix +++ b/modules/greetd/default.nix @@ -4,24 +4,41 @@ config, ... }: let + # Nix stuff optionals = lib.lists.optionals; isNvidia = config.hardware.nvidia.modesetting.enable; - user = config.services.device-vars.username; + vars = config.services.device-vars; - hyprBin = "${config.home-manager.users.${user} - .wayland.windowManager.hyprland.finalPackage}/bin"; + # Executables' paths regreetBin = "${lib.getExe config.programs.regreet.package}"; + hyprBin = "${config.home-manager.users.${vars.username} + .wayland.windowManager.hyprland.finalPackage}/bin"; - style = pkgs.writeText "style.css" ''${builtins.readFile ./style.css}''; - - setupMonitors = pkgs.writeShellScriptBin "setupMonitors" '' + # Show Regreet on all monitors + dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" '' names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name')) + main="${vars.mainMonitor}" - for (( i=1; i<''${#names[@]}; i++ )); do - ${hyprBin}/hyprctl keyword monitor ''${names[$i]},preferred,auto,1,mirror,''${names[0]} + if [[ $(echo "$main") == "null" ]]; then + main="''${names[0]}" + fi + + for (( i=0; i<''${#names[@]}; i++ )); do + if [[ ''${names[$i]} != "$main" ]]; then + ${hyprBin}/hyprctl keyword monitor ''${names[$i]},preferred,auto,1,mirror,"$main" + fi done ''; + # Check if user wants Regreet only on main monitor + setupMonitors = if vars.mainMonitor != null && !vars.greetdDupe + then "${hyprBin}/hyprctl dispatch focusmonitor ${vars.mainMonitor}" + else "${dupeMonitors}/bin/dupeMonitors"; + + # Get css for regreet + style = pkgs.writeText "style.css" ''${builtins.readFile ./style.css}''; + + # Setup Hyprland as regreet's compositor hyprConf = pkgs.writeText "greetd-hypr-config" (lib.strings.concatStrings ((optionals isNvidia [ @@ -32,8 +49,8 @@ "env = WLR_NO_HARDWARE_CURSORS,1\n" ]) ++ [ - "exec-once = ${setupMonitors}/bin/setupMonitors &&" - " swww init --no-cache &&" + "exec-once = ${setupMonitors} &&" + " sleep 1; swww init --no-cache &&" " swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n" "${builtins.readFile ./hyprland.conf}\n" diff --git a/modules/greetd/hyprland.conf b/modules/greetd/hyprland.conf index 2a2ee76..ae0c3cf 100644 --- a/modules/greetd/hyprland.conf +++ b/modules/greetd/hyprland.conf @@ -13,6 +13,16 @@ input { sensitivity = 0 # -1.0 - 1.0, 0 means no modification. } +device:razer-razer-naga-pro { + sensitivity = -0.5 + accel_profile = "flat" +} + +device:razer-razer-naga-pro-1 { + sensitivity = -0.5 + accel_profile = "flat" +} + env = XCURSOR_SIZE,24 exec-once=hyprctl setcursor Dracula-cursors 24