37 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Wrapper for Firefox finding it with my flags no matter where it's installed
# to, mainly for use with a desktop entry.
set -x
export MOZ_ENABLE_WAYLAND=1
FlagsForFirefox="--allow-downgrade $@"
inhibitcmd() {
if hash systemd-inhibit 2> /dev/null; then
systemd-inhibit --who "Firefox ($(whoami))" --why "Web browser is running, let's not autoreboot or anything" $@
else
$@
fi
}
# Firefox (stable, beta) and signatures: https://releases.mozilla.org/pub/firefox/releases/
# Developer edition (and signatures): https://releases.mozilla.org/pub/devedition/releases/
if [ -f ~/.local/firefox/firefox ]; then
inhibitcmd ~/.local/firefox/firefox $FlagsForFirefox
# Fallback to global installation
elif [ -f /usr/bin/firefox ]; then
inhibitcmd /usr/bin/firefox $FlagsForFirefox
# Fallback to global installation
elif [ -f /usr/bin/firefox-esr ]; then
inhibitcmd /usr/bin/firefox-esr $FlagsForFirefox
# Fallback to Snap which apparently follows /etc/policies.json
elif [ -f /var/lib/snapd/snap/bin/firefox ]; then
inhibitcmd snap run firefox $FlagsForFirefox
# Fallback to flatpak, don't care if it doesn't exist
else
inhibitcmd flatpak run org.mozilla.firefox $FlagsForFirefox
fi
set +x