Skip to content

Refuse to stack another Battle.net Proton tree - #13354

Open
Bartok9 wants to merge 9 commits into
omacom:quattrofrom
Bartok9:bartok9/battlenet-single-instance
Open

Bartok9 wants to merge 9 commits into
omacom:quattrofrom
Bartok9:bartok9/battlenet-single-instance

Conversation

@Bartok9

@Bartok9 Bartok9 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Summary

omarchy-launch-battlenet always ran umu-run, so closing Battle.net to tray and relaunching stacked invisible Proton trees (reported as 9 trees / 61 processes).

Window-only guards are not enough: a tray-hidden copy has no Hyprland client, and umu-run's sandbox defeats Battle.net's own single-instance lock.

Change

  • Focus an existing Battle.net window when Hyprland reports one.
  • If a umu-run tree for $HOME/Games/battlenet is already running with no window, refuse to launch another copy.
  • Tests cover the empty, windowed, and headless cases.

Closes #13344

Base: quattro.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Reviewed at fc21c17. Verified: the process guard stops a second launch while a tree started by this launcher is running. Two behavior issues remain: the refusal is not visible to someone launching from the app launcher, and the window match also picks up unrelated windows by title. The tests do not exercise the real jq filter or pgrep pattern.

Verified (isolated sandbox, mocked umu-run, mocked or unreachable hyprctl, real jq and pgrep except where the new test's own stubs are used):

  • A long-running process with the command line of Arch's packaged umu-run (python3 /usr/bin/umu-run <…/Battle.net Launcher.exe>) is matched by the real pgrep pattern, and no second umu-run starts.
  • With no window and no running tree, the launcher starts umu-run exactly as before.
  • Client classes steam_app_battlenet (from battlenet.lua) and battle.net.exe (from battlenet.desktop) are both found. The focus dispatch is the same string the other Omarchy launchers use.
  • With Hyprland not reachable, the window lookup returns nothing and the launch proceeds. --help and unknown arguments are handled before the new checks.
  • The new test passes on its own and under test/shell, and fails when the launcher change is reverted.

The refusal is not visible from the app launcher

When a tree is running with no window (the #13344 case), the launcher prints "Battle.net is already running…" to stderr and exits 0. battlenet.desktop runs without a terminal, and the app launcher starts it detached, so that line is not shown anywhere on screen. From the shell's launch feedback code, the user gets "Launching Battle.net…" after 2 s, which clears at 15 s, and then nothing.

Impact: in the #13344 situation (hidden to tray, with no usable tray icon), every relaunch is now refused silently, and there is no way back to the running client short of finding and killing its processes by hand. The issue asked to "end the stale tree (or at minimum warn)". The warning exists, but only on stderr.

Suggested change: send the message with omarchy-notification-send, which AGENTS.md asks for. Its --exec click action could offer to stop the hidden copy and start a fresh one. Stopping it automatically is riskier, since a client hidden to tray may be downloading or patching a game.

The title clause focuses unrelated windows instead of launching

The filter matches battle.?net against the class or the title, and head -n1 takes the first hit. With the real jq and the PR's filter:

Client (class, title) PR filter class only
steam_app_battlenet, any match match
battle.net.exe, any match match
chromium, Battle.net - Chromium match no match
foot, user@host:~/Games/battlenet match no match
com.mitchellh.ghostty, omarchy-launch-battlenet match no match

Impact: when Battle.net is not running, such a window is focused instead, the launcher exits 0 and Battle.net never starts (reproduced end to end with the browser row and the Ghostty-titled terminal row; the foot row was checked with jq only). When the client is running but an unrelated window is listed first, the wrong window gets focus (checked with jq only). The Ghostty row applies to users who picked Ghostty, which is optional (the default terminal, foot, does not do this): the installer suggests running omarchy-launch-battlenet from a terminal, and Ghostty's shell integration sets the tab title to the running command, which Omarchy's Ghostty config leaves enabled. The Ghostty title behavior is from source; its timing was not measured.

Suggested change: match on class only. It keeps both known client classes and rejects all three unrelated windows above:

select(.class | test("battle.?net"; "i"))

omarchy-hyprland-focus-app rejects title matches from unrelated windows for the same reason (hyprland-focus-app-test.sh).

Optional test improvement: the jq stub is a Python script that ignores the filter, and the pgrep stub ignores its pattern. The shipped test still passed with the jq regex changed to one that never matches, with the jq program made a syntax error, and with the pgrep pattern changed to one that never matches. Using the real jq (require_command jq, as other shell tests do) and having the pgrep stub check that its argument contains umu-run and the test prefix would make those cases fail. Asserting the dispatched address would also cover the window choice.

Pattern edges: $HOME is interpolated into the pgrep -f regex unescaped, so with a home directory whose name contains a regex metacharacter, such as c++dev, a running tree was not detected and a second copy launched. With no trailing /, a tree under ~/Games/battlenet-old/ also matches. A fixed-string check avoids both. Capture the pgrep output first, because piping it into grep lets pgrep list the grep process itself, which then always matches:

battlenet_running() {
  local procs
  procs=$(pgrep -af umu-run) || return 1
  grep -Fq -- "umu-run $PREFIX/" <<<"$procs"
}

In the sandbox this returned false with no tree, true with a tree (including under a c++dev home), and false for a battlenet-old sibling.

Style: AGENTS.md prefers a full if/else to exit in one branch, and treats default-package commands such as hyprctl and jq as always present; the sibling launchers call them without command -v guards.

Related open PRs:

  • Tile the Battle.net client instead of floating it #8932 adds its own battlenet_window_address and focus block at the same place in the launcher; a local merge of the two heads has a content conflict in bin/omarchy-launch-battlenet. Its description says a second umu-run "just logs 'another instance is running' and exits", which is the opposite of this PR's code comment about the single-instance lock. Neither claim was tested here.
  • Scale Battle.net to the focused monitor #12432 inserts an omarchy-games-battlenet-scale call before umu-run. The two merge cleanly, but the new test only prepends its mock directory to the inherited PATH, so on the merged tree its no-window launch case calls whichever copy of that helper the inherited PATH provides. With none on PATH, the test exited 127 with omarchy-games-battlenet-scale: command not found. A stub for the helper in the test's mock directory avoids both outcomes.

Review information

Test scope: Source review of fc21c17 against its base, plus umu-launcher 1.4.4 and Arch packaging, Hyprland v0.56.2 and Ghostty v1.3.1 source, and the diffs of open PRs #8932, #10567, #12432 and #13195. The launcher and its new test ran in an isolated sandbox with mocked hyprctl and umu-run and a umu-run-shaped dummy process. Only the two Battle.net test files ran under test/shell, not the full suite. The #8932 and #12432 interactions were checked with local merges of the PR heads. No live Hyprland, Battle.net, Wine/Proton or umu-launcher runs; tray behavior, the client's real window titles, how long a real tree lives and the launch feedback on screen were not observed.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough sandbox review on fc21c17.

Pushed 5040288 to address the actionable points:

  • Hyprland match is class-only (no title), so browser/terminal titles no longer steal focus
  • Headless relaunch refusal uses omarchy-notification-send so app-launcher users see feedback
  • Process guard is a fixed-string umu-run + $PREFIX/ check (HOME metachars / battlenet-old sibling)
  • Style: full if/else, no command -v guards for default tools
  • Tests use real jq and cover title-only false positives, sibling prefix, and notify

Noted the open-PR interactions with #8932 (focus block conflict) and #12432 (scale helper on PATH in tests); happy to adjust further if maintainers want those coordinated.

@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: At 5040288, the earlier review's behaviour findings are resolved; one wording issue is new.

  • Resolved: stderr-only refusal, title-clause matches, pattern edges, style.
  • Partly resolved: the pgrep test stub still ignores its arguments.
  • Still applies: related open PRs.

Refusal advice may not be possible

It says a copy has no window "(likely tray)" and to "Close it from the system tray or kill its umu-run tree". It also fires while umu-run is still starting (e.g. downloading GE-Proton). Impact: in #13344 (no tray icon) the only way out is a terminal command the text omits; during a slow start it advises killing that copy.

Suggested change: say "already running or still starting" and give one concrete way to stop a hidden copy (a command or --exec action).

Reproducer (message text at 5040288)

Reproducer: what the refusal notification says

Reviewed head: 50402883 (omacom/omarchy PR #13354).

Whenever a umu-run process for ~/Games/battlenet/ exists and Hyprland lists no Battle.net window, the launcher refuses and sends the notification below. The launcher cannot tell a copy hidden to tray from one that umu-run is still preparing: the umu-run command line exists from the moment it starts, before any window. This script shows the text; it does not model why no window exists.

Script

#!/bin/bash
# Usage: bash repro-notification.sh <omarchy checkout at 5040288>
# Shows what the launcher tells the user whenever a umu-run process for the
# prefix exists and Hyprland lists no Battle.net window. Nothing real is started.
set -uo pipefail

src=$(cd -- "$1" && pwd)
tmp=$(mktemp -d)
trap 'kill "${sleeper:-}" 2>/dev/null; rm -rf "$tmp"' EXIT
show() { sed "s#$tmp#\$TMP#g"; }

home="$tmp/home"
exe="$home/Games/battlenet/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe"
mkdir -p "$(dirname "$exe")" "$tmp/mock" "$tmp/fake"
: >"$exe"
printf '#!/bin/bash\n[[ $1 == clients ]] && echo "[]"\nexit 0\n' >"$tmp/mock/hyprctl"
printf '#!/bin/bash\necho "umu-run called: $*"\n' >"$tmp/mock/umu-run"
cat >"$tmp/mock/omarchy-notification-send" <<'SH'
#!/bin/bash
printf 'notification argument: %s\n' "$@"
SH
chmod +x "$tmp/mock"/*

# Stands in for a copy that is hidden to tray, or one that umu-run is still
# preparing (Proton download or runtime update) before any window exists.
printf 'import time\ntime.sleep(300)\n' >"$tmp/fake/umu-run"
(exec -a /usr/bin/python python3 "$tmp/fake/umu-run" "$exe") </dev/null >/dev/null 2>&1 &
sleeper=$!
for _ in $(seq 100); do pgrep -af umu-run | grep -Fq "$exe" && break; sleep 0.05; done

echo "running: $(pgrep -af umu-run | show)"
HOME="$home" PATH="$tmp/mock:$PATH" bash "$src/bin/omarchy-launch-battlenet" 2>&1 | show
echo "exit: ${PIPESTATUS[0]}"

Actual output

Bash 5.3.15, jq 1.8.2, procps-ng 4.0.7 pgrep, in an isolated sandbox with its own PID namespace:

running: 236 /usr/bin/python $TMP/fake/umu-run $TMP/home/Games/battlenet/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe
Battle.net is already running (no window to focus — it may be minimised to tray).
notification argument: -u
notification argument: normal
notification argument: -g
notification argument: 🎮
notification argument: Battle.net already running
notification argument: A copy is open with no window (likely tray). Close it from the system tray or kill its umu-run tree before relaunching.
exit: 0

Why the wording matters (source, not run here)

  • Issue omarchy-launch-battlenet has no single-instance guard — every relaunch stacks a headless Proton tree #13344: "Not one Battle.net copy had a tray icon or a window". Open PR Fix context menus for Wine tray items #9245 reports that the current tray cannot open a Wine item's menu, which is where Battle.net's Exit lives.
  • umu-launcher 1.4.4 (the Arch package): with PROTONPATH=GE-Proton, as the launcher sets, get_umu_proton() asks GitHub for the latest GE-Proton on each launch and _get_latest() downloads and extracts it when it is not installed yet, before Proton starts (umu/umu_proton.py). During that time the umu-run process exists and no window does. How long this takes on a real machine was not measured.
  • umu-launcher 1.4.4 run_command() installs a SIGTERM/SIGINT handler that forwards the signal to every descendant (signal_handler, get_pstree_from_pid in umu/umu_run.py), so terminating the umu-run process is meant to stop its tree. Not run against a real tree here.
Details

Verified (isolated sandbox, real jq and pgrep, stubbed hyprctl, umu-run and notification transport):

  • Browser, foot and Ghostty title-only windows no longer take focus; both client classes (steam_app_battlenet, battle.net.exe) are focused, also when an unrelated window is listed first.
  • A running umu-run-shaped process is detected under a c++dev or John Doe home; one for a battlenet-old sibling is ignored.
  • The refusal calls omarchy-notification-send with valid arguments and exits 0; with no session bus it still exits 0 promptly.
  • The new test passes on its own and under test/shell (run with only the two Battle.net test files), and fails against the fc21c17 launcher and when the title clause is restored, the trailing / is dropped, the notification call is removed or the jq program has a syntax error.

Optional test improvement: the pgrep stub prints canned lines whatever it is called with, so a launcher calling pgrep -f umu-run (no -a, PIDs only) or a misspelt pattern still passes every case, while with the real pgrep that launcher starts a second copy. Adding [[ $* == "-af umu-run" ]] || exit 2 to the stub catches both and still passes on the PR.

Related open PRs: the if/else re-indent now also conflicts with #12432 and #13195 (both merged cleanly with fc21c17); the EOF to HELP heredoc rename, unrelated to the fix, causes one of the two #13195 conflict hunks. #8932 still conflicts. #13619 is a competing fix for #13344 in the same lines, so maintainers will likely want only one. After resolving #12432's conflict, the new test calls whichever omarchy-games-battlenet-scale the inherited PATH provides (with none, it exits 127); a stub in the mock directory avoids both.

Reproducer (pgrep stub)

Reproducer: the test's pgrep stub ignores its arguments

Reviewed head: 50402883 (omacom/omarchy PR #13354).

The launcher's fixed-string check only works when pgrep prints full command lines (-a). The test's pgrep stub prints canned full lines whatever it is called with, so a launcher that calls pgrep -f umu-run (PIDs only) or searches for the wrong name still passes every assertion, while with the real pgrep the guard never fires. A stub that checks its arguments makes the test fail on that change and still passes on the PR as written.

Script

Run from anywhere, with an omarchy checkout of the PR head as the argument. It works on a throwaway copy and starts only a sleep-like Python process whose command line looks like umu-run. hyprctl, umu-run and omarchy-notification-send are stubs; pgrep and jq are real.

#!/bin/bash
# Usage: bash repro-pgrep-stub.sh <omarchy checkout at 5040288>
# Works on a throwaway copy; the checkout is not modified.
set -uo pipefail

src=$(cd -- "$1" && pwd)
tmp=$(mktemp -d)
trap 'kill "${sleeper:-}" 2>/dev/null; rm -rf "$tmp"' EXIT
show() { sed "s#$tmp#\$TMP#g"; }

mkdir -p "$tmp/tree"
cp -a "$src/bin" "$src/test" "$tmp/tree/"
launcher="$tmp/tree/bin/omarchy-launch-battlenet"
test_file="$tmp/tree/test/shell.d/launch-battlenet-test.sh"

echo "== 1. Break the guard: drop -a, so pgrep prints PIDs only"
sed -i 's/procs=$(pgrep -af umu-run/procs=$(pgrep -f umu-run/' "$launcher"
grep -n 'pgrep' "$launcher" | show

echo
echo "== 2. The PR's test still passes"
bash "$test_file" 2>&1 | show
echo "exit: ${PIPESTATUS[0]}"

echo
echo "== 3. With the real pgrep and a running umu-run-shaped process, the broken launcher starts a second copy"
home="$tmp/home"
exe="$home/Games/battlenet/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe"
mkdir -p "$(dirname "$exe")" "$tmp/mock" "$tmp/fake"
: >"$exe"
printf '#!/bin/bash\n[[ $1 == clients ]] && echo "[]"\nexit 0\n' >"$tmp/mock/hyprctl"
printf '#!/bin/bash\necho "umu-run called: $*"\n' >"$tmp/mock/umu-run"
printf '#!/bin/bash\necho "notification: $*"\n' >"$tmp/mock/omarchy-notification-send"
chmod +x "$tmp/mock"/*
printf 'import time\ntime.sleep(300)\n' >"$tmp/fake/umu-run"
(exec -a /usr/bin/python python3 "$tmp/fake/umu-run" "$exe") </dev/null >/dev/null 2>&1 &
sleeper=$!
for _ in $(seq 100); do pgrep -af umu-run | grep -Fq "$exe" && break; sleep 0.05; done
echo "running: $(pgrep -af umu-run | show)"
HOME="$home" PATH="$tmp/mock:$PATH" bash "$launcher" 2>&1 | show

echo
echo "== 4. A pgrep stub that checks its arguments makes the test catch it"
python3 - "$test_file" <<'PY'
import sys
path = sys.argv[1]
text = open(path).read()
old = '# Expect -af umu-run (or similar). Emit lines only when OMARCHY_TEST_PGREP_LINES is set.\n'
new = '[[ $* == "-af umu-run" ]] || exit 2\n'
assert text.count(old) == 1
open(path, "w").write(text.replace(old, new))
PY
bash "$test_file" 2>&1 | show
echo "exit: ${PIPESTATUS[0]}"

echo
echo "== 5. The same stricter stub passes against the unmodified launcher"
cp "$src/bin/omarchy-launch-battlenet" "$launcher"
bash "$test_file" 2>&1 | show
echo "exit: ${PIPESTATUS[0]}"

Actual output

Bash 5.3.15, jq 1.8.2, procps-ng 4.0.7 pgrep, in an isolated sandbox with its own PID namespace:

== 1. Break the guard: drop -a, so pgrep prints PIDs only
57:  procs=$(pgrep -f umu-run 2>/dev/null) || return 1

== 2. The PR's test still passes
ok - launcher starts umu-run when no Battle.net tree exists
ok - launcher focuses an existing Battle.net window
ok - launcher ignores title-only Battle.net window matches
Battle.net is already running (no window to focus — it may be minimised to tray).
ok - launcher refuses to stack a headless Battle.net tree
ok - launcher ignores battlenet-old sibling umu-run trees
exit: 0

== 3. With the real pgrep and a running umu-run-shaped process, the broken launcher starts a second copy
running: 88 /usr/bin/python $TMP/fake/umu-run $TMP/home/Games/battlenet/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe
umu-run called: $TMP/home/Games/battlenet/drive_c/Program Files (x86)/Battle.net/Battle.net Launcher.exe

== 4. A pgrep stub that checks its arguments makes the test catch it
ok - launcher starts umu-run when no Battle.net tree exists
ok - launcher focuses an existing Battle.net window
ok - launcher ignores title-only Battle.net window matches
not ok - launcher must not stack umu-run when a headless tree exists
exit: 1

== 5. The same stricter stub passes against the unmodified launcher
ok - launcher starts umu-run when no Battle.net tree exists
ok - launcher focuses an existing Battle.net window
ok - launcher ignores title-only Battle.net window matches
Battle.net is already running (no window to focus — it may be minimised to tray).
ok - launcher refuses to stack a headless Battle.net tree
ok - launcher ignores battlenet-old sibling umu-run trees
exit: 0

Suggested test change (one line in the pgrep stub)

 cat >"$mock_bin/pgrep" <<'SH'
 #!/bin/bash
-# Expect -af umu-run (or similar). Emit lines only when OMARCHY_TEST_PGREP_LINES is set.
+[[ $* == "-af umu-run" ]] || exit 2
 if [[ -n ${OMARCHY_TEST_PGREP_LINES:-} ]]; then

The same stricter stub also fails on pgrep -af umu-runX (a misspelt pattern), which the shipped stub accepts.

Reproducer (merge checks)

Reproducer: textual conflicts with related open PRs

Heads checked (2026-09-29): #13354 50402883 (earlier fc21c17a), #12432 7cd16364, #13195 1bc000dc, #13619 914e1d7c, #8932 b76c23c2, #10567 facb2e6b.

Commands

In a scratch repository:

git init -q scratch && cd scratch
git remote add origin https://github.com/omacom/omarchy.git
git fetch -q --filter=blob:none origin \
  refs/pull/13354/head:refs/pr/13354 refs/pull/12432/head:refs/pr/12432 \
  refs/pull/13195/head:refs/pr/13195 refs/pull/13619/head:refs/pr/13619 \
  refs/pull/8932/head:refs/pr/8932 refs/pull/10567/head:refs/pr/10567
for pair in "50402883 7cd16364 12432" "50402883 1bc000dc 13195" "50402883 914e1d7c 13619" \
            "50402883 b76c23c2 8932" "50402883 facb2e6b 10567" "fc21c17a 7cd16364 12432" \
            "fc21c17a 1bc000dc 13195"; do
  set -- $pair
  echo "\$ git merge-tree --write-tree --name-only $1 $2   # #13354@$1 with #$3"
  git merge-tree --write-tree --name-only $1 $2 2>&1 | sed 1d | grep -E 'CONFLICT|^bin/|^test/'
  echo "exit: ${PIPESTATUS[0]}"
done

Actual output

$ git merge-tree --write-tree --name-only 50402883 7cd16364   # #13354@50402883 with #12432
bin/omarchy-launch-battlenet
CONFLICT (content): Merge conflict in bin/omarchy-launch-battlenet
exit: 1
$ git merge-tree --write-tree --name-only 50402883 1bc000dc   # #13354@50402883 with #13195
bin/omarchy-launch-battlenet
CONFLICT (content): Merge conflict in bin/omarchy-launch-battlenet
exit: 1
$ git merge-tree --write-tree --name-only 50402883 914e1d7c   # #13354@50402883 with #13619
bin/omarchy-launch-battlenet
CONFLICT (content): Merge conflict in bin/omarchy-launch-battlenet
exit: 1
$ git merge-tree --write-tree --name-only 50402883 b76c23c2   # #13354@50402883 with #8932
bin/omarchy-launch-battlenet
CONFLICT (content): Merge conflict in bin/omarchy-launch-battlenet
exit: 1
$ git merge-tree --write-tree --name-only 50402883 facb2e6b   # #13354@50402883 with #10567
exit: 0
$ git merge-tree --write-tree --name-only fc21c17a 7cd16364   # #13354@fc21c17a with #12432
exit: 0
$ git merge-tree --write-tree --name-only fc21c17a 1bc000dc   # #13354@fc21c17a with #13195
exit: 0

The conflicts with #12432 and #13195 are new in 50402883: moving the env_args/umu-run block into the else branch re-indents the lines both PRs edit. Against #13195 the merged file has two conflict hunks; one of them is the help heredoc, where #13195 adds text above EOF and 50402883 renames EOF to HELP. With only that rename reverted on top of 50402883, the merge with #13195 has one conflict hunk instead of two.

#12432's scale call after resolving the conflict

With omarchy-games-battlenet-scale placed before umu-run in the launch branch (the obvious resolution), the PR's own test stops at its first case because run_launch only prepends its mock directory to the inherited PATH:

$TMP/merge-12432/bin/omarchy-launch-battlenet: line 82: omarchy-games-battlenet-scale: command not found
exit: 127

(Sandbox path replaced by $TMP. No copy of the helper was on PATH.)


Review information

Test scope: Source and sandbox runs at 5040288, umu-launcher 1.4.4 source; no live Hyprland, Battle.net, Proton, tray or notifications.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@Bartok9

Bartok9 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — follow-up on 4a79388.

Related-PR conflicts noted; happy to rebase once maintainers pick which Battle.net launcher change lands.

@nickryand

Copy link
Copy Markdown

@Bartok9 if you want to incorporate the same or similar functionality, I'll drop my PR. Both fixes would be great.

@Bartok9

Bartok9 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @nickryand — both fixes are complementary, and I'd rather not leave you maintaining a conflicting launcher diff.

#13195 (configurable LAUNCH_ARGS from ~/.config/omarchy/launchers/battlenet.conf, plus the gaming-manual note) is a clean per-machine scale-factor path. This PR only refuses a second headless Proton tree. I'll fold the conf-file args into this branch so you can drop #13195 once that lands here.

Until then, heads-up: 5040288 already conflicts with #13195 in bin/omarchy-launch-battlenet (the launch block moved into the else, and the help heredoc was renamed EOF → HELP). Folding your change in resolves that instead of rebasing both ways.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 4a79388 against quattro, and it fixes #13344.

Reproduced on a disposable Omarchy worker with the real umu-run from umu-launcher 1.4.4, left fetching GE-Proton, which is the state where there is a tree and no window. With that running, the quattro launcher started a second umu-run, this branch refused and started nothing, and the quattro launcher started a second one again. pgrep -af shows the real process as /usr/bin/python3 /usr/bin/umu-run <prefix>/…/Battle.net Launcher.exe, which the fixed-string check matches. With nothing running, the branch launches as before. The pkill line in the notification stops that tree.

In the running Hyprland session, with a battle.net.exe window open and a different window titled "Battle.net - Chromium" focused, the launcher focused the Battle.net client and launched nothing. With a tree running and no window, the refusal notification reached the session's notification service with the headline and text from the diff.

Tests: launch-battlenet-test.sh (5/5) and battlenet-test.sh pass on the worker. ./test/cli has one failure (vscode generated theme references current theme file), and the full ./test/shell run fails in ascii-test.sh, branding-about-animation-test.sh, kernel-headers-migration-test.sh, omarchy-kernel-migration-test.sh and passwordless-grant-lifecycle-test.sh. All of them also fail on the unmodified base, so none come from this change.

Second opinion (Codex Medium): it agreed that the problem is real, that the fixed-string check matches the real umu-run command line, and that the change is proportionate. Independence is not guaranteed, because it can read this review's working notes. It raised one point worth knowing: omarchy-install-gaming-battlenet starts its own tree as umu-run ~/.cache/omarchy/Battle.net-Setup.exe, which this check does not match. If the setup wizard leaves Battle.net running when it finishes, the first launch after installing could still start a second tree. That was not tested here, because it needs the real Battle.net download. Its other points, a race between two launches started within the same instant and a Battle.net window from a Steam or Lutris install being focused instead, behave the same way as the other omarchy-launch-* launchers, and I left them.

Related: #13619 is a newer competing fix for the same issue. This one is older and handles more: it matches the window by class only, so the "Battle.net - Chromium" window above is ignored, where #13619 also matches by title and can focus that window, and it shows a notification instead of exiting silently. This branch also conflicts textually in bin/omarchy-launch-battlenet with #8932, #12432 and #13195, so whichever lands second needs a rebase.

Nothing was pushed. It is labelled verified and waits on the maintainer: to choose between this and #13619, and to decide whether the installer case needs covering first.

@Bartok9

Bartok9 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — glad this reproduced on a real umu-run tree and a live Hyprland session, and that the suite failures also fail on unmodified quattro.

Noted the installer edge: omarchy-install-gaming-battlenet starts umu-run ~/.cache/omarchy/Battle.net-Setup.exe, which this prefix check does not match. Happy to cover that if maintainers want it before merge; otherwise I'll leave the choice between this and #13619, and whether the installer case is in scope, with you. No further changes from me unless asked.

umu-run sandboxes each launch so Battle.net never sees its own instance lock,
and tray-hidden copies have no window to focus. Focus an existing client when
one exists; otherwise skip the relaunch instead of stacking another headless
tree.

Closes omacom#13344
- Match Hyprland clients by class only (avoid browser/terminal titles)
- Fixed-string umu-run+prefix check (HOME metachars, battlenet-old)
- Notify via omarchy-notification-send when refusing a headless relaunch
- Prefer if/else over early exit; drop command -v guards
- Tests use real jq and cover title-only, sibling prefix, and notify
The notification no longer tells people to kill a tree that may still be
downloading GE-Proton, and names pkill as the way out when there is no tray.
The test stub now requires pgrep -af umu-run so a PID-only call fails.
@Bartok9
Bartok9 force-pushed the bartok9/battlenet-single-instance branch from 4a79388 to 66806da Compare October 25, 2026 21:27
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects repeat starts through the Battle.net launcher.

The overlapping-launch bug still needs a fix before merging.

Findings

  1. P1 Overlapping launches still stack copies ▶

Summary

The PR focuses an existing Battle.net window or refuses another launch when a windowless copy is running.

  • Battle.net launches focus an open window or refuse hidden copies.
  • The Battle.net help command keeps printing the same usage text.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Launch Battle.net] --> B{Window exists?}
  B -->|Yes| C[Focus window]
  B -->|No| D{umu-run copy exists?}
  D -->|Yes| E[Notify user without launching]
  D -->|No| F[Match DPI when safe and launch]
Loading

Reviews (5) · Last reviewed commit: "Detach the windowless Battle.net fixture..." · Reviewed by Greptile

hyprctl dispatch "hl.dsp.focus({ window = \"address:$WINDOW_ADDRESS\" })" >/dev/null 2>&1 ||
hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS" >/dev/null 2>&1 || true
else
if battlenet_running; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Overlapping launches still stack copies

Two near-simultaneous activations can both pass battlenet_running before either starts umu-run. Both then start separate Proton trees, leaving the duplicate-launch bug possible during startup. Hold a shared lock across the running check and launch, and add an overlapping-launch test.

Comment thread bin/omarchy-launch-battlenet Resolved
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 26, 2026
The notification title already went through omarchy-i18n, but its body was an English literal on a continuation line, where the i18n-check extractor does not look. docs/i18n.md puts every notification string in cli.json, so the body is now battlenet.alreadyRunningBody with the stop command as %1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 1038a38 against quattro after the rebase. It still fixes #13344.

Pushed 1038a38: the notification title was already read through omarchy-i18n, but the body was still an English literal. It is on a continuation line, where the i18n-check extractor does not look, which is why CI did not catch it. docs/i18n.md puts every notification string in cli.json, so the body is now battlenet.alreadyRunningBody, with the pkill command passed in as %1. This is the second point in Greptile's review. The command stays an argument, so a translation cannot alter it.

Reproduced again on a disposable Omarchy worker, using this branch merged into current quattro, with real pgrep and the session's notification service. A windowless process ran whose command line has the same shape as the real python3 /usr/bin/umu-run …/Battle.net Launcher.exe. With it running, quattro's launcher started a second tree, this head started none, and with the launcher reverted a second tree started again. The notification arrived with the catalog title and the full body, including the pkill line. With nothing running, this head started exactly one tree. Real Battle.net was not run this time. The real umu-run 1.4.4 reproduction from the last review was at 4a79388, and the guard has not changed since.

Tests: launch-battlenet-test.sh (5/5), i18n-test.sh (401/0) and ./test/cli pass on the worker with this branch merged into quattro. On the branch by itself, i18n-test.sh stops at a locale-generation step. That comes from the older omarchy-language this branch was based on; #16414 has since fixed it on quattro.

Second opinion: Codex Medium and muse-wonder (pi, thinking high) both found the change proportionate and the problem real, and confirmed that the placeholder substitution in omarchy-i18n leaves the pkill argument intact. Independence is not guaranteed, because they can read this review's working notes. Codex Medium reviewed the pushed head a second time and found nothing left to act on. A few points are still open, none of them blocking:

  • The comment at bin/omarchy-launch-battlenet:69-70 says not to tell the user to kill the tree, and the next line gives them a pkill command. The comment could say what it means now: wait, or stop the hidden copy.
  • Greptile's first point: two launches started within the same moment can both pass the check. Both reviewers rated this lower than P1. Closing it needs a lock held for the whole life of umu-run, which is a design choice.
  • A tree started by omarchy-install-gaming-battlenet (umu-run …/Battle.net-Setup.exe) is still not matched, as noted at 4a79388.
  • The suggested pkill -f treats $HOME as a regular expression. A home path with characters like + would not match the copy that the fixed-string guard detected.

#13619, the competing fix, has been closed, so this is the only open fix for #13344. It still overlaps textually with #8932, #12432 and #13195 in bin/omarchy-launch-battlenet.

It is labelled verified and waits on the maintainer to decide whether the installer and simultaneous-launch cases need covering here. CI's test job was still running when this was posted.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 6, 2026
omarchybot and others added 3 commits November 17, 2026 04:39
quattro added DPI matching to omarchy-launch-battlenet (omacom#17418, omacom#18286) and a launch-battlenet-test.sh of its own. The DPI match now runs only on the path that actually launches, so focusing an open window or refusing a windowless tree leaves user.reg alone. The guard's tests join quattro's file in its style: a real windowless process stands in for the hidden tree, so pgrep is no longer stubbed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said not to tell the user to kill the tree, while the notification below it gives them the pkill command for the hidden copy. It now says what the notification does: offer waiting first, because the tree may still be downloading GE-Proton.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sibling-prefix case passed on quattro's launcher too, so it guarded nothing the house rules count; it is gone. The EXIT trap no longer stops before removing the scratch directory when there is no process to kill, and the windowless tree is waited for at most five seconds instead of forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 17, 2026
Comment thread test/shell.d/launch-battlenet-test.sh Resolved
docs/testing.md asks background fixtures to redirect their output, so an inherited pipe cannot hold the runner open; the wineserver fixture above already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the ready Good to merge label Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed after this stopped merging cleanly into quattro. While it waited, quattro added Battle.net DPI matching to the same launcher (#17418, #18286), along with its own test/shell.d/launch-battlenet-test.sh. It still fixes #13344.

Pushed to your branch:

  • 6c16b9a merges quattro in. It is a merge, not a rebase, so your commits are unchanged. The DPI match now runs only when the launcher actually starts Battle.net. Focusing an open window or refusing a windowless copy leaves user.reg alone, because neither starts Wine. The guard's tests join quattro's test file, in its style. A real windowless process whose command line reads like umu-run's stands in for the hidden copy, so pgrep is no longer stubbed. The sibling-prefix and title-only cases are gone, because both pass without the guard. The two cases left, focus and refusal, each fail with quattro's launcher.
  • ce5d406 rewords the comment above the notification at bin/omarchy-launch-battlenet:106. It said not to tell the user to kill the tree, while the notification gives them the pkill command. It now says the notification offers waiting first.
  • 7486b82 and 3a117b2 tidy the test fixture. Its cleanup no longer stops before removing the scratch directory, its wait for the process to start is bounded, and its output is redirected as docs/testing.md asks. Codex and Greptile raised these.

Reproduced on a disposable Omarchy worker with real pgrep. A windowless process ran whose command line has the shape of the real python3 /usr/bin/umu-run …/Battle.net Launcher.exe. With it running, quattro's launcher started another tree, and this branch started none and sent the "already running" notification. With nothing running, this branch started exactly one tree.

Tests: on the worker, launch-battlenet-test.sh passes 5/5 at 3a117b2: quattro's three DPI cases plus the focus and refusal cases. It fails with quattro's launcher put back. i18n-test.sh (401 ok) and ./test/cli pass after the merge. CI's test and i18n-check jobs are green at this head.

Second opinion: Codex Medium and muse-wonder (pi, thinking high) reviewed the merge. Both agreed that moving the DPI match into the launch branch keeps everything quattro intended. Independence is not guaranteed, because they can read this review's working notes. Codex Medium found the three test-fixture problems above, and reviewed the final head twice more with nothing left open. Greptile's point about fixture output was correct and is fixed.

Still open, for the maintainer: the issue asked whether refusing with a pkill hint is the right direction, or whether the launcher should stop the stale copy itself. Two gaps noted in earlier reviews are also still uncovered: a tree started by omarchy-install-gaming-battlenet, and two launches in the same instant. Nothing is waiting on you.

It is labelled verified and ready, and waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-launch-battlenet has no single-instance guard — every relaunch stacks a headless Proton tree

4 participants