summaryrefslogtreecommitdiff
path: root/browser
blob: 57304fb7ef00f1e20e2e2ecb68c3e80212acc409 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env zsh

platform=$(uname)

if [[ "$platform" == "Linux" ]]; then

# To use mpv for youtube links
if [[ $1 != "" ]]; then
  if printf $1 2>/dev/null | grep -q "youtube.com"; then
    mpv "$1"
    exit
  fi
fi

# scale on highres displays
if [[ $(dpi) -gt 120 ]]; then
  SCALE=1.4
else
  SCALE=1.0
fi

# maybe use firefox distributed in binary
bin=$(which firefox)
if [[ $? -eq 1 ]]; then
  bin=$(which firefox-bin)
fi

# for mutt copy the file before it disappears
case "$1" in
  *tmp/pks/mutt/*)
    cp $1 $1.html
    TZ=UTC GDK_SCALE=$SCALE GDK_DPI_SCALE=$SCALE /usr/bin/env $bin -new-tab $1.html
    ;;
  *)
    TZ=UTC GDK_SCALE=$SCALE GDK_DPI_SCALE=$SCALE /usr/bin/env $bin -new-tab $@
    ;;
esac

elif [[ "$platform" == "Darwin" ]]; then
case "$1" in
  *tmp/pks/mutt/*)
    cp $1 $1.html
    open -g -j -a "Firefox" "$1.html"
    ;;
  *)
    open -g -j -a "Firefox" "$1"
    ;;
esac
return 0
fi