Repository navigation
Match Battle.net's DPI to the monitor scale on launch #17418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| tmp_dir="$(mktemp -d)" | ||
| wineserver_pid="" | ||
| trap '[[ -n $wineserver_pid ]] && kill "$wineserver_pid" 2>/dev/null; rm -rf "$tmp_dir"' EXIT | ||
|
|
||
| mkdir -p "$tmp_dir/bin" "$tmp_dir/home" | ||
| export TEST_LOG="$tmp_dir/log" | ||
| export PATH="$tmp_dir/bin:$PATH" | ||
| export HOME="$tmp_dir/home" | ||
|
|
||
| prefix="$HOME/Games/battlenet" | ||
| mkdir -p "$prefix/drive_c/Program Files (x86)/Battle.net" | ||
| touch "$prefix/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe" | ||
| # umu points WINEPREFIX at pfx/, a link back to the prefix itself. | ||
| ln -s . "$prefix/pfx" | ||
|
|
||
| # Wine's default 96 DPI, under both keys a prefix carries it in. | ||
| write_registry() { | ||
| cat >"$prefix/user.reg" <<'REG' | ||
| [Control Panel\\Desktop] 1793676771 | ||
| "LogPixels"=dword:00000060 | ||
| "MenuShowDelay"="400" | ||
|
|
||
| [Software\\Wine\\Fonts] 1793677064 | ||
| "LogPixels"=dword:00000060 | ||
| REG | ||
| } | ||
|
|
||
| cat >"$tmp_dir/bin/hyprctl" <<SCRIPT | ||
| #!/bin/bash | ||
| printf '[{"name":"DP-1","focused":false,"scale":1},{"name":"HDMI-A-1","focused":true,"scale":%s}]\n' "\$(cat "$tmp_dir/scale")" | ||
| SCRIPT | ||
| cat >"$tmp_dir/bin/umu-run" <<'SCRIPT' | ||
| #!/bin/bash | ||
| printf 'umu-run:%s\n' "$*" >>"$TEST_LOG" | ||
| SCRIPT | ||
| chmod +x "$tmp_dir/bin/hyprctl" "$tmp_dir/bin/umu-run" | ||
|
|
||
| # A fractional scale rounds to the nearest DPI: 1.6 x 96 = 153.6, so 154. | ||
| write_registry | ||
| echo 1.6 >"$tmp_dir/scale" | ||
| "$ROOT/bin/omarchy-launch-battlenet" | ||
|
|
||
| [[ $(grep -c '^"LogPixels"=dword:0000009a$' "$prefix/user.reg") == "2" ]] || | ||
| fail "Battle.net launch matches the DPI to the focused monitor's scale" "$(cat "$prefix/user.reg")" | ||
| grep -q '^"MenuShowDelay"="400"$' "$prefix/user.reg" || | ||
| fail "Battle.net launch matches the DPI to the focused monitor's scale" "other registry values changed" | ||
| grep -q '^umu-run:.*Battle.net Launcher.exe$' "$TEST_LOG" || | ||
| fail "Battle.net launch matches the DPI to the focused monitor's scale" "launcher never started" | ||
| pass "Battle.net launch matches the DPI to the focused monitor's scale" | ||
|
|
||
| # While the prefix's wineserver runs, the registry is its to write back on | ||
| # exit, so the launch leaves it alone and still hands off to the launcher. | ||
| ln -s "$(command -v sleep)" "$tmp_dir/wineserver" | ||
| WINEPREFIX="$prefix/pfx/" "$tmp_dir/wineserver" 60 & | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| wineserver_pid=$! | ||
| write_registry | ||
| echo 2 >"$tmp_dir/scale" | ||
| : >"$TEST_LOG" | ||
| "$ROOT/bin/omarchy-launch-battlenet" | ||
|
|
||
| [[ $(grep -c '^"LogPixels"=dword:00000060$' "$prefix/user.reg") == "2" ]] || | ||
| fail "Battle.net launch leaves a running prefix's DPI alone" "$(cat "$prefix/user.reg")" | ||
| grep -q '^umu-run:.*Battle.net Launcher.exe$' "$TEST_LOG" || | ||
| fail "Battle.net launch leaves a running prefix's DPI alone" "launcher never started" | ||
| pass "Battle.net launch leaves a running prefix's DPI alone" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.