feat: allow use of desc: id for mainMonitor

This commit is contained in:
matt1432 2023-12-05 15:07:50 -05:00
parent 6893948ade
commit 0d75b0d487
4 changed files with 12 additions and 7 deletions

View file

@ -27,9 +27,10 @@
};
mainMonitor = mkOption {
type = types.nullOr types.str;
type = types.str;
description = ''
The name of the main monitor used for Hyprland and Regreet
The name of the main monitor used for Hyprland
and Regreet which also uses Hyprland
'';
default = "null";
};

View file

@ -18,7 +18,7 @@
vars = {
user = "matt";
hostName = "binto";
mainMonitor = "DP-5";
mainMonitor = "desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
greetdDupe = false;
fontSize = 12.5;
};

Binary file not shown.

View file

@ -23,16 +23,20 @@
# Show Regreet on all monitors
dupeMonitors = pkgs.writeShellScriptBin "dupeMonitors" ''
names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .name'))
main="${config.vars.mainMonitor}"
names=($(${hyprBin}/hyprctl -j monitors | ${pkgs.jq}/bin/jq -r '.[] .description'))
if [[ $(echo "$main") == "null" ]]; then
if [[ "$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"
name=$(echo "''${names[$i]}" | sed 's/.*(\(.*\))/\1/')
desc=$(echo "''${names[$i]}" | sed 's/ (.*//')
if [[ "$name" != "$main" && "desc:$desc" != "$main" ]]; then
${hyprBin}/hyprctl keyword monitor "$name",preferred,auto,1,mirror,"$main"
fi
done
'';