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 18 additions and 13 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;
};

View file

@ -358,11 +358,11 @@
"xdph": "xdph"
},
"locked": {
"lastModified": 1701737536,
"narHash": "sha256-xSmfHhhCL9mAta5jKfcbJxYjCoD2MdLPBMjBUWvYAJI=",
"lastModified": 1701790877,
"narHash": "sha256-xNjSypJirandCE1/OLFwndGYhFdoSqcbjW77rVZ86uI=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "3bb9c7c5cf4f2ee30bf821501499f2308d616f94",
"rev": "37d7a8c64dfabfe81330c819c24fd6b13b292194",
"type": "github"
},
"original": {
@ -749,11 +749,11 @@
},
"nur": {
"locked": {
"lastModified": 1701780125,
"narHash": "sha256-HtNkw7mbLPkxmSoz57FNXEMioFMIBp7yDy88dE3HsZA=",
"lastModified": 1701798379,
"narHash": "sha256-o+uFCoZalr5csUdWD84I2ELd78VGxt9+8PZbJXwaHA8=",
"owner": "nix-community",
"repo": "NUR",
"rev": "77fbdb7bff2c28e35f755144d9313faf3f8121ed",
"rev": "e3ef2421e85a36a8b5650cfb3cc9096f53059609",
"type": "github"
},
"original": {

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
'';