aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/script/dmenu-browser
blob: a367c0e5985c64ca01d05e8631005f2e13604db7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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" "<i>Not found: $(echo "$1" | awk '{ print $1 }') or $(echo "$2" | awk '{ print $1 }')</i>\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