hyprland: make monitor config dependent on config.monitors

This commit is contained in:
2026-07-19 09:08:50 +02:00
parent de081fe38f
commit 76ad137946
3 changed files with 23 additions and 24 deletions
+15 -2
View File
@@ -60,8 +60,12 @@
wf-recorder
wl-clipboard
(pkgs.writeShellScriptBin "toggle-screen-mirroring" (
builtins.readFile ./toggle-screen-mirroring.sh
(pkgs.writeShellScriptBin "toggle-screen-mirroring"
(
builtins.replaceStrings
["@INTERNAL_MONITOR@" "@EXTERNAL_MONITOR@"]
[(builtins.elemAt config.monitors 0).name (builtins.elemAt config.monitors 1).name]
(builtins.readFile ./toggle-screen-mirroring.sh)
))
(pkgs.writeShellScriptBin "correct-workspace-locations" (
@@ -108,6 +112,15 @@
''
+ "-- Main config from `hyprland.lua`\n"
+ builtins.readFile ./hyprland.lua
+ "-- Monitor config\n"
+ lib.concatStringsSep "\n" (
map (
monitor: "hl.monitor({ output = \"${monitor.name}\", mode = \"preferred\", position = \"auto\", scale = \"auto\", mirror = \"\"})"
)
config.monitors
)
+ "\n-- For plugging in random monitors\n"
+ "hl.monitor({ output = \"\", mode = \"preferred\", position = \"auto\", scale = \"auto\", mirror = \"\"})\n"
+ "-- Assign workspaces to monitors\n"
+ lib.concatStringsSep "\n" (
builtins.concatLists (
@@ -1,16 +1,3 @@
------------------
---- MONITORS ----
------------------
-- See https://wiki.hypr.land/Configuring/Basics/Monitors/
hl.monitor({
output = "",
mode = "preferred",
position = "auto",
scale = "auto",
mirror = "",
})
-------------------
---- AUTOSTART ----
-------------------
@@ -2,11 +2,10 @@
# A hyprland script for a laptop-external-monitor setup, toggling between which is in use
# TODO: Detect these instead of hardcoding them
INTERNAL_MONITOR="eDP-1"
EXTERNAL_MONITOR="HDMI-A-1"
INTERNAL_MONITOR="@INTERNAL_MONITOR@"
EXTERNAL_MONITOR="@EXTERNAL_MONITOR@"
MIRROR_SETTING=$(hyprctl monitors all -j | jq -r '.[] | select(.name == "HDMI-A-1") | .mirrorOf')
MIRROR_SETTING=$(hyprctl monitors all -j | jq -r --arg EXTERNAL "$EXTERNAL_MONITOR" '.[] | select(.name == $EXTERNAL) | .mirrorOf')
echo "current setting: "
echo $MIRROR_SETTING