From 43134875b5ef7f36f9b7946ea478b3db3ade7eac Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 15 May 2026 16:07:35 +0200 Subject: [PATCH] Ensure that $BROWSER runs omarchy-launch-browser and doesn't hand ownership to parent process This prevents gh auth login from working without an existing open browser --- bin/omarchy-launch-browser | 6 ++++-- config/uwsm/default | 3 +++ migrations/1778851263.sh | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 migrations/1778851263.sh diff --git a/bin/omarchy-launch-browser b/bin/omarchy-launch-browser index fefc935e..f1076e79 100755 --- a/bin/omarchy-launch-browser +++ b/bin/omarchy-launch-browser @@ -6,7 +6,7 @@ default_browser=$(xdg-settings get default-web-browser) browser_exec=$(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$default_browser 2>/dev/null | head -1) -if $browser_exec --help | grep -q MOZ_LOG; then +if $browser_exec --help 2>/dev/null | grep -q MOZ_LOG; then private_flag="--private-window" elif [[ $browser_exec =~ edge ]]; then private_flag="--inprivate" @@ -14,4 +14,6 @@ else private_flag="--incognito" fi -exec setsid uwsm-app -- "$browser_exec" "${@/--private/$private_flag}" +systemd-run --user --quiet --collect --unit="omarchy-browser-$(date +%s%N)" \ + --property=StandardOutput=null --property=StandardError=null \ + uwsm-app -- "$browser_exec" "${@/--private/$private_flag}" diff --git a/config/uwsm/default b/config/uwsm/default index 946fbe5f..92836d0c 100644 --- a/config/uwsm/default +++ b/config/uwsm/default @@ -3,6 +3,9 @@ # Install other terminals via Install > Terminal export TERMINAL=xdg-terminal-exec +# Used by terminal programs (like gh) to open URLs detached from the terminal process tree +export BROWSER=omarchy-launch-browser + # Use code for VSCode export EDITOR=nvim diff --git a/migrations/1778851263.sh b/migrations/1778851263.sh new file mode 100644 index 00000000..3b3a4fe7 --- /dev/null +++ b/migrations/1778851263.sh @@ -0,0 +1,11 @@ +echo "Set BROWSER to Omarchy browser launcher for detached terminal URL opens" + +if [[ -f ~/.config/uwsm/default ]]; then + if grep -q '^export BROWSER=' ~/.config/uwsm/default; then + sed -i 's|^export BROWSER=.*|export BROWSER=omarchy-launch-browser|' ~/.config/uwsm/default + else + printf '\n# Used by terminal programs (like gh) to open URLs detached from the terminal process tree\nexport BROWSER=omarchy-launch-browser\n' >> ~/.config/uwsm/default + fi +else + omarchy-refresh-config uwsm/default +fi