Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/omarchy-launch-browser
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ if [[ -z $default_browser ]]; then
fi
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 2>/dev/null | grep -q MOZ_LOG; then
# Detected by executable name rather than probing `--help`: Chrome's `--help`
# execs `man` to show its manual page, and on an image without man-db that
# exec fails with ENOENT and kills Chrome with SIGTRAP before it ever launches.
if [[ $browser_exec =~ firefox|librewolf|zen|floorp ]]; then
private_flag="--private-window"
elif [[ $browser_exec =~ edge ]]; then
private_flag="--inprivate"
Expand Down
21 changes: 21 additions & 0 deletions test/shell.d/launch-browser-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ grep -Fx '^chromium.*$' "$focus_log" >/dev/null ||
fail "browser launcher focuses the browser resolved from the HTTPS handler"

pass "browser launcher follows opened links to the browser workspace"

# Chrome's --help execs `man` to show its manual page. On an image without
# man-db that exec fails and kills Chrome with SIGTRAP, so private-mode
# detection must never invoke the browser's --help to figure out its flag.
help_probe_log="$test_tmp/help-probe"
cat >"$mock_bin/chromium" <<SH
#!/bin/bash
if [[ \$1 == "--help" ]]; then
printf 'probed\n' >"$help_probe_log"
exit 1
fi
exit 0
SH
chmod +x "$mock_bin/chromium"

HOME="$test_home" PATH="$mock_bin:$PATH" HYPRLAND_INSTANCE_SIGNATURE=test \
OMARCHY_TEST_BROWSER_LAUNCH="$launch_log" OMARCHY_TEST_BROWSER_FOCUS="$focus_log" \
bash "$ROOT/bin/omarchy-launch-browser" --private

[[ ! -e $help_probe_log ]] || fail "browser launcher never probes the browser with --help"
pass "browser launcher decides the private-mode flag without invoking --help"