surf-open.sh (1126B)
1 #!/bin/sh 2 3 prefix="" 4 #prefix="torsocks" 5 #prefix="firejail --profile=$HOME/.config/firejail/surf.config" 6 xidfile="/tmp/tabbed-surf-$(whoami).xid" 7 surfxidfile="/tmp/surf-$(whoami).xid" 8 uri="" 9 10 [ "$#" -gt 0 ] && uri="$1" 11 12 if command -v surf-clean-cookies >/dev/null 2>&1; then 13 surf-clean-cookies 14 fi 15 16 screen_resolution() { 17 xdpyinfo | awk '/screen #0/ {getline; gsub(/.*x/, "", $2); print $2; exit}' 18 } 19 20 runtabbed() { 21 echo "starting tabbed" 22 nohup tabbed -dn tabbed-surf -r 2 >"$xidfile" 2>/dev/null & 23 sleep 1 24 } 25 opensurf() { 26 zoomlevel="1.0" 27 if [ "$(screen_resolution)" -gt 1500 ]; then 28 zoomlevel="2.5" 29 fi 30 nohup $prefix surf $SURFFLAGS -z "$zoomlevel" -e "$xid" \ 31 -u 'Mozilla/5.0 (X11; OpenBSD amd64; rv:76.0) Gecko/20100101 Firefox/76.0' \ 32 "$uri" >"$surfxidfile" 2>/dev/null & 33 } 34 35 [ ! -r "$xidfile" ] && runtabbed 36 37 proxyport="$(ps x | grep '[s]sh -D ' | sed 's,.*-D ,,; s, .*,,')" 38 if [ -n "$proxyport" ]; then 39 export http_proxy="socks://localhost:${proxyport}" 40 fi 41 42 xid=$(cat "$xidfile") 43 if ! xprop -id "$xid" >/dev/null 2>&1; then 44 runtabbed 45 fi 46 opensurf 47 case "$SURFFLAGS" in 48 *-w*) sleep 1; cat "$surfxidfile";; 49 esac