Limit monitor scale stepping to normal range
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
test_tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$test_tmp"' EXIT
|
||||
|
||||
stub_bin="$test_tmp/bin"
|
||||
eval_out="$test_tmp/hyprctl-eval"
|
||||
home_dir="$test_tmp/home"
|
||||
monitor_lua="$home_dir/.config/hypr/monitors.lua"
|
||||
|
||||
mkdir -p "$stub_bin" "$home_dir/.config/hypr"
|
||||
|
||||
cat >"$stub_bin/hyprctl" <<'SH'
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $1 == "monitors" && $2 == "-j" ]]; then
|
||||
printf '[{"name":"eDP-1","focused":true,"scale":%s,"width":2880,"height":1800,"refreshRate":120.0}]' "${OMARCHY_TEST_MONITOR_SCALE:-2}"
|
||||
elif [[ $1 == "eval" ]]; then
|
||||
printf '%s\n' "$2" >"$OMARCHY_TEST_HYPRCTL_EVAL_OUT"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
SH
|
||||
chmod +x "$stub_bin/hyprctl"
|
||||
|
||||
write_monitor_config() {
|
||||
cat >"$monitor_lua" <<'LUA'
|
||||
local omarchy_gdk_scale = 2
|
||||
local omarchy_monitor_scale = 2
|
||||
LUA
|
||||
}
|
||||
|
||||
run_scaling() {
|
||||
HOME="$home_dir" \
|
||||
PATH="$stub_bin:$PATH" \
|
||||
OMARCHY_TEST_HYPRCTL_EVAL_OUT="$eval_out" \
|
||||
OMARCHY_TEST_MONITOR_SCALE="${OMARCHY_TEST_MONITOR_SCALE:-2}" \
|
||||
"$ROOT/bin/omarchy-hyprland-monitor-scaling" "$@"
|
||||
}
|
||||
|
||||
write_monitor_config
|
||||
OMARCHY_TEST_MONITOR_SCALE=2 run_scaling up
|
||||
grep -F 'scale = 2' "$eval_out" >/dev/null || fail "monitor scaling up stops at 2x"
|
||||
grep -Fx 'local omarchy_monitor_scale = 2' "$monitor_lua" >/dev/null || fail "monitor scaling up does not persist 3x from 2x"
|
||||
pass "monitor scaling up stops at 2x"
|
||||
|
||||
write_monitor_config
|
||||
OMARCHY_TEST_MONITOR_SCALE=3 run_scaling down
|
||||
grep -F 'scale = 2' "$eval_out" >/dev/null || fail "monitor scaling down recovers 3x to 2x"
|
||||
grep -Fx 'local omarchy_monitor_scale = 2' "$monitor_lua" >/dev/null || fail "monitor scaling down persists 2x from 3x"
|
||||
pass "monitor scaling down recovers 3x to 2x"
|
||||
|
||||
write_monitor_config
|
||||
OMARCHY_TEST_MONITOR_SCALE=2 run_scaling 3
|
||||
grep -F 'scale = 3' "$eval_out" >/dev/null || fail "monitor scaling explicit 3x remains available"
|
||||
grep -Fx 'local omarchy_monitor_scale = 3' "$monitor_lua" >/dev/null || fail "monitor scaling explicit 3x persists"
|
||||
pass "monitor scaling explicit 3x remains available"
|
||||
|
||||
scale=$(OMARCHY_TEST_MONITOR_SCALE=3 run_scaling)
|
||||
[[ $scale == "3" ]] || fail "monitor scaling reports explicit 3x scale" "actual: $scale"
|
||||
pass "monitor scaling reports explicit 3x scale"
|
||||
Reference in New Issue
Block a user