Merge pull request #6353 from zainsyedz/fix-clamshell-internal-monitor-config

Respect internal monitor config in clamshell recovery
This commit is contained in:
David Heinemeier Hansson
2026-07-24 10:31:00 -07:00
committed by GitHub
2 changed files with 40 additions and 2 deletions
+26 -2
View File
@@ -30,13 +30,24 @@ configured_monitor_scale() {
local monitor_lua="$HOME/.config/hypr/monitors.lua"
[[ -f $monitor_lua ]] || return 0
local scale
scale=$(sed -n 's/^local omarchy_monitor_scale = //p' "$monitor_lua" | head -1)
scale=$(configured_internal_monitor_value scale)
if [[ -z $scale ]]; then
scale=$(sed -n 's/^local omarchy_monitor_scale = //p' "$monitor_lua" | head -1)
fi
if [[ -z $scale ]]; then
scale=$(sed -nE 's/^hl\.monitor\(\{ output = "", mode = "preferred", position = "auto", scale = ([^ ]+) \}\)/\1/p' "$monitor_lua" | head -1)
fi
echo "$scale"
}
configured_internal_monitor_value() {
local key="$1"
local monitor_lua="$HOME/.config/hypr/monitors.lua"
[[ -n $INTERNAL && -f $monitor_lua ]] || return 0
sed -nE '/^hl\.monitor\(\{.*output = "'"$INTERNAL"'".*\}\)/s/.*'"$key"' = "?([^", }]+)"?.*/\1/p' "$monitor_lua" | head -1
}
current_internal_scale() {
[[ -n $INTERNAL ]] || return 0
hyprctl monitors all -j | jq -r --arg internal "$INTERNAL" '.[] | select(.name == $internal and .disabled != true) | .scale' | head -1
@@ -75,11 +86,24 @@ read_monitor_scale() {
echo 2
}
read_monitor_position() {
local position
position=$(configured_internal_monitor_value position)
if [[ $position =~ ^[-[:alnum:]_.+]+$ ]]; then
echo "$position"
return
fi
echo auto
}
enable_internal_output() {
[[ -n $INTERNAL ]] || return 0
local scale="${1:-}"
local position
[[ -n $scale ]] || scale=$(read_monitor_scale)
hyprctl eval "hl.monitor({ output = \"$INTERNAL\", mode = \"preferred\", position = \"auto\", scale = $scale })" >/dev/null 2>&1 || true
position=$(read_monitor_position)
hyprctl eval "hl.monitor({ output = \"$INTERNAL\", mode = \"preferred\", position = \"$position\", scale = $scale })" >/dev/null 2>&1 || true
}
sync_internal_scale() {
@@ -65,6 +65,13 @@ local omarchy_monitor_scale = "auto"
LUA
}
write_internal_monitor_config() {
cat >"$monitor_lua" <<'LUA'
hl.monitor({ output = "eDP-1", mode = "preferred", position = "0x0", scale = 1.25 })
hl.monitor({ output = "", mode = "preferred", position = "auto-right", scale = 1 })
LUA
}
run_clamshell() {
HOME="$home_dir" \
PATH="$stub_bin:$PATH" \
@@ -102,3 +109,10 @@ OMARCHY_TEST_INTERNAL_DISABLED=true run_clamshell
grep -F 'scale = 1.6' "$eval_log" >/dev/null || fail "clamshell recovery uses remembered internal scale"
! grep -F 'scale = "auto"' "$eval_log" >/dev/null || fail "clamshell recovery avoids auto after disabled internal display"
pass "clamshell recovery uses remembered internal scale"
write_internal_monitor_config
: >"$eval_log"
OMARCHY_TEST_INTERNAL_DISABLED=true run_clamshell
grep -F 'position = "0x0"' "$eval_log" >/dev/null || fail "clamshell recovery uses configured internal position"
grep -F 'scale = 1.25' "$eval_log" >/dev/null || fail "clamshell recovery uses configured internal scale"
pass "clamshell recovery uses configured internal monitor rule"