diff options
Diffstat (limited to 'X/xsession.d/browser.sh')
-rw-r--r-- | X/xsession.d/browser.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/X/xsession.d/browser.sh b/X/xsession.d/browser.sh new file mode 100644 index 00000000..024075d6 --- /dev/null +++ b/X/xsession.d/browser.sh @@ -0,0 +1,26 @@ +# Choose a GUI browser with some rough heuristics + +# If LibreWolf or failing that Firefox is available, start by assuming that +if command -v librewolf >/dev/null 2>&1 ; then + BROWSER=librewolf +elif command -v firefox >/dev/null 2>&1 ; then + BROWSER=firefox +fi + +# Consider a switch to Dillo... +if ( + # No output, please + exec >/dev/null 2>&1 + # Don't switch if it's not there + command -v dillo || exit 1 + # Do switch if neither LibreWolf nor Firefox are there + command -v librewolf || command -v firefox || exit 0 + # Do switch if procfs says we have less than 2GB of RAM + awk '$1=="MemTotal:"&&$2<2^20{m++}END{exit!m}' < /proc/meminfo +) ; then + BROWSER=dillo +fi + +# Export our choice of browser, if it isn't empty +[ -n "$BROWSER" ] || return +export BROWSER |