hyprland: make monitor config dependent on config.monitors
This commit is contained in:
@@ -60,9 +60,13 @@
|
||||
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" (
|
||||
lib.concatStringsSep "\n" (
|
||||
@@ -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,18 +2,17 @@
|
||||
|
||||
# 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
|
||||
if [ "$MIRROR_SETTING" = "none" ]; then
|
||||
echo "mirroring..."
|
||||
hyprctl eval "hl.monitor({output=\"$EXTERNAL_MONITOR\", mode=\"preferred\", position=\"auto\", scale=\"auto\", mirror=\"$INTERNAL_MONITOR\"})"
|
||||
echo "mirroring..."
|
||||
hyprctl eval "hl.monitor({output=\"$EXTERNAL_MONITOR\", mode=\"preferred\", position=\"auto\", scale=\"auto\", mirror=\"$INTERNAL_MONITOR\"})"
|
||||
else
|
||||
# hyprctl keyword monitor "$EXTERNAL_MONITOR, disable" # shortly disable monitor so waybar recognizes the new monitor again # TODO: find better solution
|
||||
hyprctl eval "hl.monitor({output=\"$EXTERNAL_MONITOR\", mode=\"preferred\", position=\"auto\", scale=\"auto\", mirror=\"\"})"
|
||||
# hyprctl keyword monitor "$EXTERNAL_MONITOR, disable" # shortly disable monitor so waybar recognizes the new monitor again # TODO: find better solution
|
||||
hyprctl eval "hl.monitor({output=\"$EXTERNAL_MONITOR\", mode=\"preferred\", position=\"auto\", scale=\"auto\", mirror=\"\"})"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user