3
# Copyright 2011 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
6
# Wrapper that provides a default Xvfb environment for the given
9
# If the command is not found it is searched for in the same directory
10
# as this script. This lets you do `bin/with-xvfb iharness` for
13
# Follows sinzui's advice to the launchpad-dev list:
14
# https://lists.launchpad.net/launchpad-dev/msg07879.html
19
# Look for $1 - i.e. the command to run - in this script's directory
20
# if it's not found along the default PATH.
21
if [ $# -ge 1 ] && ! type -P "$1" > /dev/null
23
if command="$(PATH="$(dirname "$0")" type -P "$1")"
25
# Shift $1 off and set new positional arguments.
26
shift && set -- "$${command}" "$@"
28
# If no command has been given and SHELL is set, spawn a shell.
29
elif [ $# -eq 0 -a -n "$${SHELL:-}" ]
36
# Try to get a free server number, starting at 99. See xvfb-run(1).
39
# -ac disables host-based access control mechanisms. See Xserver(1).
40
# -screen forces a screen configuration. At the time of writing
41
# there is some disagreement between xvfb-run(1) and Xvfb(1)
42
# about what the default is.
45
--server-args="-ac -screen 0 1024x768x24" \
46
--auto-servernum -- "$@"