diff --git a/bin/omarchy-cmd-browser-exec b/bin/omarchy-cmd-browser-exec new file mode 100755 index 000000000000..6343cac324a0 --- /dev/null +++ b/bin/omarchy-cmd-browser-exec @@ -0,0 +1,92 @@ +#!/bin/bash + +# omarchy:summary=Shared desktop-entry Exec parsing for browser commands (source this file) +# omarchy:hidden=true + +# Undo the escapes every desktop entry string carries. +desktop_string() { + local string=$1 char i + REPLY="" + for (( i = 0; i < ${#string}; i++ )); do + char=${string:i:1} + if [[ $char == "\\" ]]; then + (( i++ )) + case ${string:i:1} in + s) char=" " ;; + n) char=$'\n' ;; + t) char=$'\t' ;; + r) char=$'\r' ;; + "\\") char="\\" ;; + *) char="\\${string:i:1}" ;; + esac + fi + REPLY+=$char + done +} + +desktop_exec_argv() { + local desktop=$1 + local file="" line="" name="" data_dir entry_line exec_found=0 name_found=0 + desktop_exec_argv=() + desktop_exec_file="" + desktop_exec_class="" + # Read Exec= from the same data dirs omarchy-cmd-default-browser searched, in + # the same order, so the command always comes from the entry that was checked. + local -a data_dirs + IFS=: read -ra data_dirs <<<"${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + for data_dir in "${data_dirs[@]}"; do + file="$data_dir/applications/$desktop" + [[ -f $file ]] || continue + while IFS= read -r entry_line || [[ -n $entry_line ]]; do + entry_line=${entry_line%$'\r'} + if (( ! exec_found )) && [[ $entry_line == Exec=* ]]; then + line=${entry_line#Exec=} + exec_found=1 + elif (( ! name_found )) && [[ $entry_line == Name=* ]]; then + name=${entry_line#Name=} + name_found=1 + elif [[ -z $desktop_exec_class && $entry_line == StartupWMClass=* ]]; then + desktop_exec_class=${entry_line#StartupWMClass=} + fi + done <"$file" + break + done + [[ -n $line ]] || return 1 + desktop_exec_file=$file + desktop_string "$name" + name=$REPLY + + # Split the Exec line by its own quoting, expanding %c and %k, keeping %% as + # %, and dropping the other field codes. A standalone -- goes too, or the + # launcher's own options after it would be read as operands. + desktop_string "$line" + local value=$REPLY arg="" char i quoted=0 started=0 + for (( i = 0; i < ${#value}; i++ )); do + char=${value:i:1} + if [[ $char == '"' ]]; then + (( quoted = !quoted, started = 1 )) + elif [[ $char == "\\" ]] && (( quoted )); then + (( i++ )) + arg+=${value:i:1} + elif [[ $char == "%" ]]; then + (( i++ )) + case ${value:i:1} in + "%") arg+="%" started=1 ;; + c) arg+=$name started=1 ;; + k) arg+=$file started=1 ;; + esac + elif [[ $char == " " ]] && (( ! quoted )); then + if (( started )) && [[ $arg != "--" ]]; then + desktop_exec_argv+=("$arg") + fi + arg="" started=0 + else + arg+=$char started=1 + fi + done + if (( started )) && [[ $arg != "--" ]]; then + desktop_exec_argv+=("$arg") + fi + + (( ${#desktop_exec_argv[@]} > 0 )) +} diff --git a/bin/omarchy-cmd-default-browser b/bin/omarchy-cmd-default-browser index 9f64136a6b93..c730d57c378d 100755 --- a/bin/omarchy-cmd-default-browser +++ b/bin/omarchy-cmd-default-browser @@ -12,28 +12,30 @@ IFS=: read -ra data_dirs <<<"${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIR IFS=: read -ra config_dirs <<<"${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}" IFS=: read -ra desktops <<<"${XDG_CURRENT_DESKTOP:-}" -# Installed means the command of the entry the launchers will read, the first -# one found, still resolves: an entry of Omarchy's own can outlive the browser -# it launched. +source "$OMARCHY_PATH/bin/omarchy-cmd-browser-exec" + +# An env prefix can outlive its browser; check that browser on the PATH the +# entry supplies, while leaving Flatpak app IDs to their installed wrapper. installed() { - local data_dir line command - - for data_dir in "${data_dirs[@]}"; do - [[ -r $data_dir/applications/$1 ]] || continue - command="" - while IFS= read -r line || [[ -n $line ]]; do - line=${line%$'\r'} - if [[ $line == Exec=* ]]; then - command=${line#Exec=} - command=${command%% *} - break - fi - done <"$data_dir/applications/$1" - [[ -n $command ]] && command -v "$command" >/dev/null - return - done + local command assignment path=$PATH i=0 + local -a desktop_exec_argv + desktop_exec_argv "$1" || return 1 + command=${desktop_exec_argv[0]} + + if [[ $command == "env" || $command == */env ]]; then + i=1 + while [[ ${desktop_exec_argv[i]:-} == *=* && ${desktop_exec_argv[i]} != -* ]]; do + assignment=${desktop_exec_argv[i]} + [[ $assignment == PATH=* ]] && path=${assignment#PATH=} + (( i++ )) + done + # Option-bearing env wrappers keep their existing availability check. + if [[ ${desktop_exec_argv[i]:-} != -* ]]; then + command=${desktop_exec_argv[i]:-} + fi + fi - return 1 + [[ -n $command ]] && PATH=$path type -P "$command" >/dev/null } read_default_http() { diff --git a/bin/omarchy-launch-browser b/bin/omarchy-launch-browser index d8b80f8533d9..bada2b6760a4 100755 --- a/bin/omarchy-launch-browser +++ b/bin/omarchy-launch-browser @@ -5,41 +5,62 @@ default_browser=$(omarchy-cmd-default-browser) -# Read Exec= from the same data dirs omarchy-cmd-default-browser searched, in -# the same order, so the command always comes from the entry that was checked. -IFS=: read -ra data_dirs <<<"${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" -browser_exec="" -browser_class="" -for data_dir in "${data_dirs[@]}"; do - entry="$data_dir/applications/$default_browser" - [[ -f $entry ]] || continue - while IFS= read -r line || [[ -n $line ]]; do - line=${line%$'\r'} - if [[ -z $browser_exec && $line == Exec=* ]]; then - browser_exec=${line#Exec=} - browser_exec=${browser_exec%% *} - elif [[ -z $browser_class && $line == StartupWMClass=* ]]; then - browser_class=${line#StartupWMClass=} - fi - [[ -n $browser_exec && -n $browser_class ]] && break - done <"$entry" - break -done +source "$OMARCHY_PATH/bin/omarchy-cmd-browser-exec" # Handing an empty command to uwsm-app surfaces as "Command not found: \"\"", # which fails a keybinding silently. Say what is missing and how to fix it. -if [[ -z $browser_exec ]]; then +if ! desktop_exec_argv "$default_browser"; then echo "omarchy-launch-browser: no default browser found; set one with 'omarchy default browser '" >&2 omarchy-notification-send -u critical -g 󰖟 "$(omarchy-i18n browser.notFound)" "$(omarchy-i18n browser.notFoundHint)" exit 1 fi +browser_class=$desktop_exec_class + +# The browser is what an env or flatpak wrapper runs, including inside an +# env -S string; a Flatpak's is its app id, which is no command on the host. +browser_exec="" flatpak_app="" flatpak=0 +tokens=("${desktop_exec_argv[@]}") +for (( i = 0; i < ${#tokens[@]}; i++ )); do + token=${tokens[i]} + case $token in + -u | --unset | -C | --chdir) (( i++ )) ;; + -S | --split-string | -S?* | --split-string=*) + if [[ $token == "-S" || $token == "--split-string" ]]; then + split_value=${tokens[i + 1]} + rest=("${tokens[@]:i+2}") + else + split_value=${token#--split-string=} + split_value=${split_value#-S} + rest=("${tokens[@]:i+1}") + fi + mapfile -t split < <(xargs -r -n1 printf '%s\n' <<<"$split_value" 2>/dev/null) + tokens=("${tokens[@]:0:i}" "${split[@]}" "${rest[@]}") + (( i-- )) + ;; + "" | *=* | env | */env | run | -*) ;; + flatpak | */flatpak) flatpak=1 ;; + *) + browser_exec=$token + (( flatpak )) && flatpak_app=$token + break + ;; + esac +done +[[ -n $browser_exec ]] || browser_exec=${desktop_exec_argv[0]} + # Only a private launch needs the browser's flag, and probing a Firefox-family # browser's --help starts the whole binary, so ordinary launches skip it and -# leave their arguments as they are. +# leave their arguments as they are. A Flatpak is named by its app id instead. private_flag="--private" if [[ " $* " == *" --private "* ]]; then - if $browser_exec --help 2>/dev/null | grep -q MOZ_LOG; then + if [[ -n $flatpak_app ]]; then + case ${flatpak_app,,} in + org.mozilla.firefox | io.gitlab.librewolf-community | app.zen_browser.zen | net.waterfox.waterfox | one.ablaze.floorp) private_flag="--private-window" ;; + com.microsoft.edge) private_flag="--inprivate" ;; + *) private_flag="--incognito" ;; + esac + elif "$browser_exec" --help 2>/dev/null | grep -q MOZ_LOG; then private_flag="--private-window" elif [[ $browser_exec =~ edge ]]; then private_flag="--inprivate" @@ -48,10 +69,10 @@ if [[ " $* " == *" --private "* ]]; then fi fi -if ! omarchy-cmd-browser-handoff "$browser_exec" "${@/--private/$private_flag}"; then +if ! omarchy-cmd-browser-handoff "${desktop_exec_argv[@]}" "${@/--private/$private_flag}"; then systemd-run --user --quiet --collect --unit="omarchy-browser-$(date +%s%N)" \ --property=StandardOutput=null --property=StandardError=null \ - uwsm-app -- "$browser_exec" "${@/--private/$private_flag}" + uwsm-app -- "${desktop_exec_argv[@]}" "${@/--private/$private_flag}" fi url="" diff --git a/bin/omarchy-launch-webapp b/bin/omarchy-launch-webapp index 40634a0ef681..64670903acc1 100755 --- a/bin/omarchy-launch-webapp +++ b/bin/omarchy-launch-webapp @@ -11,35 +11,21 @@ chromium* | google-chrome* | brave* | microsoft-edge* | opera* | vivaldi* | heli *) browsers=(google-chrome.desktop chromium.desktop) ;; esac -# Read Exec= from the same data dirs omarchy-cmd-default-browser searched, as -# omarchy-launch-browser does, so a browser it resolved is one this can start. -IFS=: read -ra data_dirs <<<"${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" -browser_exec="" +source "$OMARCHY_PATH/bin/omarchy-cmd-browser-exec" + for browser in "${browsers[@]}"; do - for data_dir in "${data_dirs[@]}"; do - entry="$data_dir/applications/$browser" - [[ -f $entry ]] || continue - while IFS= read -r line || [[ -n $line ]]; do - line=${line%$'\r'} - if [[ $line == Exec=* ]]; then - browser_exec=${line#Exec=} - browser_exec=${browser_exec%% *} - break - fi - done <"$entry" - break 2 - done + desktop_exec_argv "$browser" && break done # Handing an empty command to uwsm-app surfaces as "Command not found: \"\"", # which fails a keybinding silently. A web app runs in a Chromium-based # browser, so say that rather than claiming no browser is set. -if [[ -z $browser_exec ]]; then +if (( ${#desktop_exec_argv[@]} == 0 )); then echo "omarchy-launch-webapp: web apps need a Chromium-based browser; install Chromium with 'omarchy install browser chromium'" >&2 omarchy-notification-send -u critical -g 󰖟 "$(omarchy-i18n browser.webappNeedsChromium)" "$(omarchy-i18n browser.webappNeedsChromiumHint)" exit 1 fi -if ! omarchy-cmd-browser-handoff "$browser_exec" --app="$1" "${@:2}"; then - exec setsid uwsm-app -- "$browser_exec" --app="$1" "${@:2}" +if ! omarchy-cmd-browser-handoff "${desktop_exec_argv[@]}" --app="$1" "${@:2}"; then + exec setsid uwsm-app -- "${desktop_exec_argv[@]}" --app="$1" "${@:2}" fi diff --git a/test/shell.d/default-browser-lookup-test.sh b/test/shell.d/default-browser-lookup-test.sh index 5a5b80e1f6c5..14e3205fcf12 100644 --- a/test/shell.d/default-browser-lookup-test.sh +++ b/test/shell.d/default-browser-lookup-test.sh @@ -38,6 +38,7 @@ echo "Exec=brave %U" >"$XDG_DATA_DIRS/applications/brave-browser.desktop" # a system copy that the launchers would never read. echo "Exec=removed-browser %U" >"$XDG_DATA_HOME/applications/removed.desktop" echo "Exec=brave %U" >"$XDG_DATA_DIRS/applications/removed.desktop" +echo "Exec=env DRI_PRIME=0 removed-browser %U" >"$XDG_DATA_HOME/applications/env-removed.desktop" cat >"$XDG_CONFIG_HOME/mimeapps.list" <<'EOF' [Added Associations] @@ -45,7 +46,7 @@ x-scheme-handler/http=firefox.desktop; [Default Applications] text/html=firefox.desktop -x-scheme-handler/http=missing.desktop;removed.desktop;chromium.desktop; +x-scheme-handler/http=missing.desktop;removed.desktop;env-removed.desktop;chromium.desktop; EOF [[ $(omarchy-cmd-default-browser) == "chromium.desktop" ]] || @@ -119,3 +120,28 @@ chmod +x "$mock_bin/xdg-settings" "$mock_bin/xdg-mime" fail "default browser skips an xdg-settings answer that is not installed" "$(omarchy-cmd-default-browser)" pass "default browser checks that fallback answers are installed" + +# An env prefix may quote a value with spaces and provide its own browser PATH. +mkdir -p "$test_tmp/opt/bin" +printf '#!/bin/bash\n' >"$test_tmp/opt/bin/custom-browser" +chmod +x "$test_tmp/opt/bin/custom-browser" +echo 'Exec=env "CHROME_CONFIG_HOME=/home/alex/Browser Profiles" chromium %U' >"$XDG_DATA_HOME/applications/quoted.desktop" +echo "Exec=env PATH=$test_tmp/opt/bin:/usr/bin custom-browser %U" >"$XDG_DATA_HOME/applications/custom-path.desktop" + +# Flatpak exports name a host wrapper, not an executable for the app ID. +printf '#!/bin/bash\n' >"$mock_bin/flatpak" +chmod +x "$mock_bin/flatpak" +echo 'Exec=flatpak run org.mozilla.firefox %u' >"$XDG_DATA_HOME/applications/flatpak.desktop" + +# Equals signs in env options must not turn those options into assignments. +echo 'Exec=env "--split-string=A=1 firefox" %u' >"$XDG_DATA_HOME/applications/env-options.desktop" + +printf 'Exec=chromium\r\n' >"$XDG_DATA_HOME/applications/crlf.desktop" + +for entry in quoted.desktop custom-path.desktop flatpak.desktop env-options.desktop crlf.desktop; do + printf '[Default Applications]\nx-scheme-handler/http=%s\n' "$entry" >"$XDG_CONFIG_HOME/mimeapps.list" + [[ $(omarchy-cmd-default-browser) == "$entry" ]] || + fail "default browser accepts $entry" "$(omarchy-cmd-default-browser)" +done + +pass "default browser checks quoted env prefixes, their PATH, Flatpak wrappers and CRLF entries" diff --git a/test/shell.d/launch-browser-test.sh b/test/shell.d/launch-browser-test.sh index f87ababec11c..f79cf141538d 100644 --- a/test/shell.d/launch-browser-test.sh +++ b/test/shell.d/launch-browser-test.sh @@ -51,7 +51,7 @@ exit 0 SH cat >"$mock_bin/systemd-run" <<'SH' #!/bin/bash -printf '%s\n' "$*" >"$OMARCHY_TEST_BROWSER_LAUNCH" +printf '%s\n' "$@" >"$OMARCHY_TEST_BROWSER_LAUNCH" SH cp "$mock_bin/systemd-run" "$mock_bin/uwsm-app" cat >"$mock_bin/omarchy-hyprland-focus-app" <<'SH' @@ -142,9 +142,123 @@ pass "an ordinary launch doesn't probe the browser's flags" launch --private [[ -s $help_log ]] || fail "a private launch probes the browser's private flag" -grep -F -- 'chromium --incognito' "$launch_log" >/dev/null || fail "a private launch passes the browser's private flag" +[[ $(sed '1,/^--$/d' "$launch_log") == $'chromium\n--incognito' ]] || fail "a private launch passes the browser's private flag" pass "a private launch passes the browser's private flag" +printf '[Desktop Entry]\r\nName=Work Chromium\r\nExec=chromium --name %%c %%U\r\nStartupWMClass=chromium-crlf\r\n' >"$test_home/.local/share/applications/chromium.desktop" +rm -f "$focus_log" +HYPRLAND_INSTANCE_SIGNATURE=test launch "https://example.test/crlf" +expected=$(printf '%s\n' chromium --name "Work Chromium" https://example.test/crlf) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "a CRLF entry passes its decoded name and URL without carriage returns" "$(cat "$launch_log")" +grep -Fx '^chromium-crlf$' "$focus_log" >/dev/null || + fail "a CRLF entry focuses its declared window class" "$(cat "$focus_log")" +pass "browser launcher reads CRLF Exec, Name and StartupWMClass values" + +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Exec=/usr/bin/env LIBVA_DRIVER_NAME=iHD chromium "--profile-directory=Work Profile" --class=100%% %U +EOF + +rm -f "$focus_log" +HOME="$test_home" PATH="$mock_bin:$ROOT/bin:$PATH" HYPRLAND_INSTANCE_SIGNATURE=test \ + OMARCHY_TEST_BROWSER_LAUNCH="$launch_log" OMARCHY_TEST_BROWSER_FOCUS="$focus_log" \ + bash "$ROOT/bin/omarchy-launch-browser" "https://example.test/wrapped" + +expected=$(printf '%s\n' /usr/bin/env LIBVA_DRIVER_NAME=iHD chromium "--profile-directory=Work Profile" --class=100% https://example.test/wrapped) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "wrapped Exec launcher runs the whole unquoted Exec line, then the URL" +grep -Fx '^chromium.*$' "$focus_log" >/dev/null || + fail "wrapped Exec launcher focuses the real browser, not env" +pass "browser launcher resolves env-wrapped desktop Exec lines" + +rm -f "$help_log" +launch --private +[[ -s $help_log ]] || fail "a wrapped private launch probes the real browser, not env" +expected=$(printf '%s\n' /usr/bin/env LIBVA_DRIVER_NAME=iHD chromium "--profile-directory=Work Profile" --class=100% --incognito) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "a wrapped private launch passes the real browser's private flag" +pass "a wrapped private launch passes the real browser's private flag" + +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Name=Work\sChromium +Exec=/usr/bin/env -u BROWSER chromium --name %c -- https://start.example.test/ %U +EOF + +rm -f "$help_log" +launch --private +[[ -s $help_log ]] || fail "a private launch probes the browser behind env -u, not the name it unsets" +expected=$(printf '%s\n' /usr/bin/env -u BROWSER chromium --name "Work Chromium" https://start.example.test/ --incognito) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "a private launch expands %c and keeps its flag an option despite the Exec line's --" +pass "a private launch finds the browser behind env options and keeps its flag an option" + +cat >"$mock_bin/firefox" <<'SH' +#!/bin/bash +[[ $1 != "--help" ]] || { printf 'probed\n' >>"$OMARCHY_TEST_BROWSER_HELP"; echo MOZ_LOG; } +SH +chmod +x "$mock_bin/firefox" +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Exec=/usr/bin/env -S "LABEL='Work Browser' MOZ_ENABLE_WAYLAND=1 firefox" %u +EOF + +rm -f "$help_log" +launch --private +[[ -s $help_log ]] || fail "a private launch probes the browser inside env -S, not env" +expected=$(printf '%s\n' /usr/bin/env -S "LABEL='Work Browser' MOZ_ENABLE_WAYLAND=1 firefox" --private-window) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "a private launch passes the private flag of the browser inside env -S" +pass "a private launch finds the browser inside env -S" + +cp "$mock_bin/chromium" "$mock_bin/flatpak" +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Exec=/usr/bin/env GDK_BACKEND=wayland flatpak run --branch=stable --arch=x86_64 --command=firefox --file-forwarding org.mozilla.firefox @@u %u @@ +EOF + +launch --private +expected=$(printf '%s\n' /usr/bin/env GDK_BACKEND=wayland flatpak run --branch=stable --arch=x86_64 --command=firefox --file-forwarding org.mozilla.firefox @@u @@ --private-window) +[[ $(sed '1,/^--$/d' "$launch_log") == "$expected" ]] || + fail "a private launch of a Flatpak Firefox passes --private-window from its app id" +pass "a private launch names a Flatpak browser's flag from its app id" + +cat >"$mock_bin/setsid" <<'SH' +#!/bin/bash +exec "$@" +SH +chmod +x "$mock_bin/setsid" +launch_webapp() { + HOME="$test_home" PATH="$mock_bin:$ROOT/bin:$PATH" OMARCHY_TEST_BROWSER_LAUNCH="$launch_log" \ + bash "$ROOT/bin/omarchy-launch-webapp" "$@" +} + +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Exec=/usr/bin/env LIBVA_DRIVER_NAME=iHD chromium "--profile-directory=Work Profile" %U +EOF + +launch_webapp "https://discord.com/channels/@me" --start-maximized +expected=$(printf '%s\n' -- /usr/bin/env LIBVA_DRIVER_NAME=iHD chromium "--profile-directory=Work Profile" \ + --app=https://discord.com/channels/@me --start-maximized) +[[ $(<"$launch_log") == "$expected" ]] || + fail "web app launcher runs the whole Exec line, then --app and the caller's arguments" "$(cat "$launch_log")" +pass "web app launcher resolves env-wrapped desktop Exec lines" + +cat >"$test_home/.local/share/applications/chromium.desktop" <<'EOF' +[Desktop Entry] +Name=Chromium +Exec=chromium --class=%c --desktop=%k -- %U +EOF + +launch_webapp "https://example.test/app" +expected=$(printf '%s\n' -- chromium --class=Chromium "--desktop=$test_home/.local/share/applications/chromium.desktop" \ + --app=https://example.test/app) +[[ $(<"$launch_log") == "$expected" ]] || + fail "web app launcher expands %c and %k and keeps --app ahead of the Exec line's --" "$(cat "$launch_log")" +pass "web app launcher expands %c and %k and keeps --app an option" + # The resolver reads every XDG data dir, so the launcher has to read Exec= # from the same ones; a browser outside ~/.local and /usr used to resolve and # then launch an empty command. @@ -165,7 +279,7 @@ EOF rm -f "$launch_log" launch "https://example.test/vivaldi" -grep -F -- ' -- vivaldi https://example.test/vivaldi' "$launch_log" >/dev/null || +[[ $(sed '1,/^--$/d' "$launch_log") == $'vivaldi\nhttps://example.test/vivaldi' ]] || fail "a browser in XDG_DATA_DIRS launches from its desktop entry" "$(cat "$launch_log")" pass "browser launcher reads Exec= from the data dirs the resolver searched" @@ -240,7 +354,7 @@ cat >"$XDG_DATA_DIRS/applications/chromium.desktop" <<'EOF' Exec=chromium %U EOF launch_webapp -grep -F -- '-- chromium --app=https://example.test/app' "$launch_log" >/dev/null || +[[ $(<"$launch_log") == $'--\nchromium\n--app=https://example.test/app' ]] || fail "a web app falls back to Chromium without Chrome" "$(cat "$launch_log" 2>/dev/null)" cat >"$XDG_DATA_DIRS/applications/google-chrome.desktop" <<'EOF' @@ -249,6 +363,6 @@ Exec=google-chrome-stable %U EOF cp "$mock_bin/chromium" "$mock_bin/google-chrome-stable" launch_webapp -grep -F -- '-- google-chrome-stable --app=https://example.test/app' "$launch_log" >/dev/null || +[[ $(<"$launch_log") == $'--\ngoogle-chrome-stable\n--app=https://example.test/app' ]] || fail "a web app falls back to Chrome over Chromium" "$(cat "$launch_log" 2>/dev/null)" pass "web app launcher falls back to Chrome, then Chromium, when the default is not Chromium-based"