aboutsummaryrefslogtreecommitdiff
path: root/X/xinitrc.d/browser.sh
blob: b6e1d57eb36cecad4390eb56b396fba8dc376b3d (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
# Choose a GUI browser with some rough heuristics

# If Librewolf is available, start by assuming that
if command -v librewolf >/dev/null 2>&1 ; then
    BROWSER=librewolf
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
    # Switch if Librewolf isn't there
    command -v librewolf || exit 0
    # 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