#!/bin/sh
# $OpenBSD: chrome,v 1.8 2012/01/11 16:24:07 ajacoutot Exp $

DATASIZE="716800"
OPENFILES="400"

xm_log() {
	echo -n "$@\nDo you want to run Chromium anyway?\n\
(If you don't increase these limits, Chromium might fail to work properly.)" | \
		${X11BASE}/bin/xmessage -file - -center -buttons yes:0,no:1 -default no
}

if [ $(ulimit -Sd) -lt ${DATASIZE} ]; then
	ulimit -Sd ${DATASIZE} || \
		xm_log "Cannot increase datasize-cur to at least ${DATASIZE}"
		[ $? -eq 0 ] || exit
fi

if [ $(ulimit -Sn) -lt ${OPENFILES} ]; then
	ulimit -Sn ${OPENFILES} || \
		xm_log "Cannot increase openfiles-cur to at least ${OPENFILES}"
		[ $? -eq 0 ] || exit
fi

exec "${TRUEPREFIX}/chrome/chrome" "${@}"
