* Read the default browser from mimeapps.list when launching omarchy-launch-browser and omarchy-launch-webapp asked xdg-settings for the default browser on every launch, ~72ms through several POSIX shell scripts. The new omarchy-cmd-default-browser reads the http handler from the config-dir mimeapps.list files the way xdg-mime does, desktop-specific list first, taking the first listed entry whose command is installed, in ~10ms. With nothing set there it falls back to xdg-settings as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Let the first copy of a browser entry decide whether it is installed A user-local entry whose browser is gone could be rescued by a system copy of the same ID, which the launchers never read. xdg-mime judges the first copy found, as the launchers use it, so do the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
960 B
Bash
Executable File
32 lines
960 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Launch the default browser as determined by xdg-settings.
|
|
# omarchy:args=[url]
|
|
|
|
default_browser=$(omarchy-cmd-default-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 2>/dev/null | grep -q MOZ_LOG; then
|
|
private_flag="--private-window"
|
|
elif [[ $browser_exec =~ edge ]]; then
|
|
private_flag="--inprivate"
|
|
else
|
|
private_flag="--incognito"
|
|
fi
|
|
|
|
systemd-run --user --quiet --collect --unit="omarchy-browser-$(date +%s%N)" \
|
|
--property=StandardOutput=null --property=StandardError=null \
|
|
uwsm-app -- "$browser_exec" "${@/--private/$private_flag}"
|
|
|
|
url=""
|
|
for argument in "$@"; do
|
|
if [[ $argument != "--private" ]]; then
|
|
url=$argument
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ -n $url && -n ${HYPRLAND_INSTANCE_SIGNATURE:-} ]]; then
|
|
omarchy-hyprland-focus-app "^$(basename "$browser_exec" -stable).*$" || true
|
|
fi
|