diff --git a/bin/omarchy-hyprland-monitor-clamshell b/bin/omarchy-hyprland-monitor-clamshell index 8bd501f1..dc896317 100755 --- a/bin/omarchy-hyprland-monitor-clamshell +++ b/bin/omarchy-hyprland-monitor-clamshell @@ -9,9 +9,23 @@ MANUAL_DISABLE_FLAG="$TOGGLES_DIR/internal-monitor-disable.lua" INTERNAL=$(hyprctl monitors all -j | jq -r '.[] | select(.name | contains("eDP")).name' | head -n 1) +read_monitor_scale() { + local monitor_lua="$HOME/.config/hypr/monitors.lua" + [[ -f $monitor_lua ]] || { echo '"auto"'; return; } + local scale + scale=$(sed -n 's/^local omarchy_monitor_scale = //p' "$monitor_lua" | head -1) + if [[ -z $scale ]]; then + scale=$(sed -nE 's/^hl\.monitor\(\{ output = "", mode = "preferred", position = "auto", scale = ([^ ]+) \}\)/\1/p' "$monitor_lua" | head -1) + fi + [[ -z $scale ]] && scale='"auto"' + echo "$scale" +} + enable_internal_output() { [[ -n $INTERNAL ]] || return 0 - hyprctl eval "hl.monitor({ output = \"$INTERNAL\", mode = \"preferred\", position = \"auto\", scale = \"auto\" })" >/dev/null 2>&1 || true + local scale + scale=$(read_monitor_scale) + hyprctl eval "hl.monitor({ output = \"$INTERNAL\", mode = \"preferred\", position = \"auto\", scale = $scale })" >/dev/null 2>&1 || true } dpms_internal() { diff --git a/test/shell.d/monitor-recovery-test.sh b/test/shell.d/monitor-recovery-test.sh index 5ef6a1c4..3cf42549 100755 --- a/test/shell.d/monitor-recovery-test.sh +++ b/test/shell.d/monitor-recovery-test.sh @@ -46,7 +46,8 @@ grep -F 'disabled = true' "$clamshell" >/dev/null grep -F 'MANUAL_DISABLE_FLAG' "$clamshell" >/dev/null ! grep -F 'rm -f "$MANUAL_DISABLE_FLAG"' "$clamshell" >/dev/null ! grep -F '>"$MANUAL_DISABLE_FLAG"' "$clamshell" >/dev/null -grep -F 'hyprctl eval "hl.monitor({ output = \"$INTERNAL\", mode = \"preferred\", position = \"auto\", scale = \"auto\" })"' "$clamshell" >/dev/null +grep -F 'read_monitor_scale' "$clamshell" >/dev/null +grep -F 'scale = $scale' "$clamshell" >/dev/null grep -F 'hyprctl dispatch "hl.dsp.dpms({ action = \"$action\", monitor = \"$INTERNAL\" })"' "$clamshell" >/dev/null grep -F 'hyprctl monitors all -j' "$clamshell" >/dev/null grep -F 'omarchy-hyprland-monitor-external-active' "$clamshell" >/dev/null