Fix `omarchy theme set` or `omarchy update` hanging forever
Read /usr/bin/omarchy-theme-set-browser, /usr/bin/omarchy-theme-set, /usr/bin/omarchy-theme-refresh, /usr/bin/omarchy-migrate, /usr/bin/omarchy-update and /usr/share/omarchy/migrations/1787481315.sh on this workstation at omarchy 4.0.2-1, and fetched bin/omarchy-theme-set-browser from omacom/omarchy at quattro. The mechanism holds: refresh_running_browser brave brave still guards on pgrep -x brave, the refresh call is still in the foreground with no timeout, run_parallel's wait still has none, and migration 1787481315 still calls omarchy-theme-refresh, so a hang there leaves the marker unwritten. Issue 8158 supports every claim in the record, including the pgrep -x brave false positive across brave-origin and the suggested refresh_running_browser /opt/brave-bin/ brave -f. Issue 8243 supports the Keychron K8 Pro hang in omarchy-theme-set-keyboard-f16, and I confirmed that script calls qmk_hid with no bound. Issue 8212, which the record did not use, adds that a correctly detected Chromium took 68 seconds and that a bound needs timeout -k, so the defect is wider than the Brave detection mix-up and the cause now says so. Three things were wrong or misleading and are rewritten. The danger claimed a Ctrl+C risks a partial upgrade, but omarchy-update runs omarchy-migrate after omarchy-update-system-pkgs has completed the pacman -Syu and no pacman hook calls the theme scripts, so at the hang point there is no transaction to interrupt. The recovery command pkill -f 'brave --refresh-platform-policy --no-startup-window' is unanchored and matches the command line of the shell it is typed in, which I confirmed here with pgrep -af, so it is replaced with an anchored pgrep and a kill by PID. Paths are moved to the installed 4.0.2-1 form, and the fix now notes that /usr/share/omarchy/bin/omarchy-theme-set-browser is a symlink to /usr/bin/omarchy-theme-set-browser and that sed -i on the symlink path would replace it. Not exercised: neither brave-bin nor brave-origin-bin is installed here, so the hanging refresh itself was never reproduced and that part rests on issue 8158. The basecamp URLs redirect but the repository is now omacom/omarchy, so the citations are moved to the canonical name.
A migration that hangs never records its marker, so that migration and every one behind it stay pending and re-run on the next omarchy update. omarchy-update runs omarchy-migrate after omarchy-update-system-pkgs has finished its pacman -Syu, so interrupting the hang does not risk a partial upgrade, but it does abandon the rest of the update: the post-update hook, AUR packages, mise, and the orphan prune. Kill the stray browser process and let the update continue rather than pressing Ctrl+C. Any edit to /usr/bin/omarchy-theme-set-browser is reverted by the next omarchy update, because that file is owned by the omarchy package.
Symptom
omarchy theme set <any-theme> never returns. Or omarchy update hangs inside a migration, for example 1787481315 ("Re-stage the current theme so an installed theme's code is dropped"), never writes that migration's marker file, so every later omarchy update re-runs it and hangs again. pgrep -af -- '--refresh-platform-policy' shows a stray browser refresh, most often /usr/bin/brave --refresh-platform-policy --no-startup-window.
Cause
omarchy-theme-set-browser calls the browser refresh in the foreground with nothing bounding it. Confirmed unchanged in omarchy 4.0.2-1 and on the quattro branch, in /usr/bin/omarchy-theme-set-browser:
refresh_running_browser() {
local process="$1"
local command="$2"
local pgrep_args="${3:--x}"
if omarchy-cmd-present "$command" && pgrep $pgrep_args "$process" >/dev/null; then
"$command" --refresh-platform-policy --no-startup-window &>/dev/null
fi
}
omarchy-theme-set runs that script as one of its 14 post_theme_commands through run_parallel, whose wait has no timeout, so a refresh that does not return holds the theme change open forever.
There are two ways in. The first is a detection mix-up: the plain-Brave branch is guarded by pgrep -x brave, and brave-origin's processes are all named plain brave, so with brave-origin running and Brave not running the guard passes and the script launches the other binary, /usr/bin/brave from brave-bin. With --no-startup-window that instance has no window to close and never exits. The second is a refresh that is slow even when detection is right, which is not Brave-specific: a correctly detected Chromium was measured at 68 seconds.
omarchy update is caught because migration 1787481315 ("Re-stage the current theme so an installed theme's code is dropped") calls omarchy-theme-refresh, which calls omarchy-theme-set. omarchy-migrate writes a migration's marker only once the script exits, so a hung migration stays pending and every later omarchy update re-runs it. omarchy-theme-set-keyboard-f16 fails the same way for a different reason: it calls qmk_hid with no bound and blocks on a QMK or VIA keyboard such as a Keychron K8 Pro.
Fix
Find the stray refresh process and kill it by PID. Anchor the pattern at the start of the command line, because an unanchored pkill -f also matches the shell you typed it in and the terminal running the update:
pgrep -af -- '^/usr/bin/brave --refresh-platform-policy'
kill <pid>
Confirm the false positive:
pgrep -xc brave # non-zero
pgrep -af brave | grep -v origin # nothing, so real Brave is NOT running
readlink -f /usr/bin/brave /usr/bin/brave-origin
Simplest permanent avoidance: quit brave-origin before a theme change or an update.
pkill -f -- '^/opt/brave-origin-bin/'
omarchy update
Or patch the guard to match on the binary path the way the brave-origin branch already does. The file to edit is /usr/bin/omarchy-theme-set-browser. /usr/share/omarchy/bin/omarchy-theme-set-browser is only a symlink to it, and sed -i on that path would replace the symlink with a regular file instead of patching the script:
sudo sed -i 's|^refresh_running_browser brave brave$|refresh_running_browser /opt/brave-bin/ brave -f|' \
/usr/bin/omarchy-theme-set-browser
That fixes the detection mix-up and nothing else. To bound every browser refresh, including a correctly detected one that is merely slow, change the call inside refresh_running_browser to:
timeout -k 1 10 "$command" --refresh-platform-policy --no-startup-window &>/dev/null
The -k is what makes it a bound. Plain timeout sends SIGTERM and then waits for a child that ignores it. The policy is read at the browser's next launch anyway, so abandoning the live refresh costs nothing.
If the machine has a QMK or VIA keyboard such as a Keychron K8 Pro and the hang is in omarchy-theme-set-keyboard-f16 instead, unplug the keyboard and retry.
Verify
omarchy theme set tokyo-night completes in a few seconds. omarchy update runs the pending migration through to completion and writes its marker, so a second omarchy update does not re-run it.