#!/bin/sh # # vncdisplay - print the name of the VNC display, first starting # the vncserver if none is available for me # # $Id$ FirstVncDisplayOfMine() { env PATH=/usr/sbin:${PATH} lsof -c Xvnc | awk '$3 == "'`whoami`'" && $NF == "(LISTEN)" && $(NF-1) ~ /:59/ { print $(NF-1); exit }' | awk -F: '{print $1 ":" $(NF)-5900}' } FirstVncDisplayOfMine | if read displayname then echo $displayname elif vncserver -localhost -depth 16 -geometry 1600x1200 then FirstVncDisplayOfMine else echo $0: cannot start VNC server 1>&2 exit 1 fi