#!/bin/sh run_either() { if type "$(echo "$1" | awk '{ print $1 }')" 1>/dev/null 2>&1; then # shellcheck disable=SC2086 setsid -f $1 elif type "$(echo "$2" | awk '{ print $1 }')" 1>/dev/null 2>&1; then if echo "$2" | grep -qi "chrom"; then # shellcheck disable=SC2046,SC2086 setsid -f $2 $(xargs < "${XDG_CONFIG_HOME:-$HOME/.config}/chromium-flags.conf") else # shellcheck disable=SC2086 setsid -f $2 fi else notify-send "Browser is not installed" "Not found: $(echo "$1" | awk '{ print $1 }') or $(echo "$2" | awk '{ print $1 }')\n\nInstall one of these with your system package manager or Flatpak" fi } browser="$(printf "Firefox\nFirefox Developer\nTor Browser\nChromium\nungoogled-chromium\nqutebrowser\nGNOME Web\n" | dmenu -i -p "Browser")" case "$browser" in "Firefox") run_either firefox org.mozilla.firefox;; "Firefox Developer") run_either firefox-developer-edition "org.mozilla.firefox -p dev-edition-default";; "Tor Browser") run_either torbrowser-launcher org.torproject.torbrowser-launcher;; "Chromium") run_either chromium org.chromium.Chromium;; "ungoogled-chromium") run_either ungoogled-chromium com.github.Eloston.UngoogledChromium;; "qutebrowser") run_either qutebrowser org.qutebrowser.qutebrowser;; "GNOME Web") run_either epiphany org.gnome.Epiphany;; *) setsid -f "$browser" esac