feat(greetd): add option to only show on main monitor

This commit is contained in:
matt1432 2023-11-25 19:24:33 -05:00
parent 3a3c8457da
commit cd6d62efc5
4 changed files with 55 additions and 10 deletions

View file

@ -14,6 +14,22 @@
type = types.nullOr types.str; 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 { fontSize = mkOption {
type = types.nullOr types.float; type = types.nullOr types.float;
}; };

View file

@ -18,6 +18,8 @@
services.device-vars = { services.device-vars = {
username = "matt"; username = "matt";
configDir = "/home/matt/.nix/devices/binto/config"; configDir = "/home/matt/.nix/devices/binto/config";
mainMonitor = "DP-5";
greetdDupe = false;
fontSize = 12.5; fontSize = 12.5;
}; };

View file

@ -4,24 +4,41 @@
config, config,
... ...
}: let }: let
# Nix stuff
optionals = lib.lists.optionals; optionals = lib.lists.optionals;
isNvidia = config.hardware.nvidia.modesetting.enable; isNvidia = config.hardware.nvidia.modesetting.enable;
user = config.services.device-vars.username; vars = config.services.device-vars;
hyprBin = "${config.home-manager.users.${user} # Executables' paths
.wayland.windowManager.hyprland.finalPackage}/bin";
regreetBin = "${lib.getExe config.programs.regreet.package}"; 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}''; # Show Regreet on all monitors
dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" ''
setupMonitors = pkgs.writeShellScriptBin "setupMonitors" ''
names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name')) names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name'))
main="${vars.mainMonitor}"
for (( i=1; i<''${#names[@]}; i++ )); do if [[ $(echo "$main") == "null" ]]; then
${hyprBin}/hyprctl keyword monitor ''${names[$i]},preferred,auto,1,mirror,''${names[0]} 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 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 = hyprConf =
pkgs.writeText "greetd-hypr-config" pkgs.writeText "greetd-hypr-config"
(lib.strings.concatStrings ((optionals isNvidia [ (lib.strings.concatStrings ((optionals isNvidia [
@ -32,8 +49,8 @@
"env = WLR_NO_HARDWARE_CURSORS,1\n" "env = WLR_NO_HARDWARE_CURSORS,1\n"
]) ])
++ [ ++ [
"exec-once = ${setupMonitors}/bin/setupMonitors &&" "exec-once = ${setupMonitors} &&"
" swww init --no-cache &&" " sleep 1; swww init --no-cache &&"
" swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n" " swww img -t none ${pkgs.dracula-theme}/wallpapers/waves.png\n"
"${builtins.readFile ./hyprland.conf}\n" "${builtins.readFile ./hyprland.conf}\n"

View file

@ -13,6 +13,16 @@ input {
sensitivity = 0 # -1.0 - 1.0, 0 means no modification. 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 env = XCURSOR_SIZE,24
exec-once=hyprctl setcursor Dracula-cursors 24 exec-once=hyprctl setcursor Dracula-cursors 24