Skip to content

Commit

Permalink
Improve xvfb script (#143)
Browse files Browse the repository at this point in the history
* Make it executable
* Add shebang
* Improve formatting
* Move pidfile to $XDG_RUNTIME_DIR

Fixes #143.
  • Loading branch information
dniku committed Jun 6, 2019
1 parent 06d3db0 commit 7f5a518
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions xvfb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#taken from https://gist.github.com/jterrace/2911875
#!/usr/bin/env bash
# taken from https://gist.github.com/jterrace/2911875

XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=./xvfb.pid

if [ -z "$XDG_RUNTIME_DIR" ];
then
export XDG_RUNTIME_DIR=/run/user/$(id -u)
fi

if ! touch $XDG_RUNTIME_DIR/.can_i_write 2>/dev/null;
then
export XDG_RUNTIME_DIR=~/.run/user/$(id -u)
mkdir -p $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR
fi

PIDFILE=$XDG_RUNTIME_DIR/xvfb.pid

case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
Expand All @@ -18,8 +34,8 @@ case "$1" in
$0 start
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
esac

exit 0
exit 0

0 comments on commit 7f5a518

Please sign in to comment.