diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2009-08-27 02:51:45 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2009-08-27 02:51:45 +0800 |
commit | f9447e339a56d396f2f109b312bcdfb32e4d6be9 (patch) | |
tree | 6e14ffdb547bbaeef7cf015edce324c92eb0418f /sysutils/consolekit/files/ck-get-x11-display-device | |
parent | 6387e0581c9136115888c8cc4def1288df7f4334 (diff) | |
download | marcuscom-ports-f9447e339a56d396f2f109b312bcdfb32e4d6be9.tar.gz marcuscom-ports-f9447e339a56d396f2f109b312bcdfb32e4d6be9.tar.zst marcuscom-ports-f9447e339a56d396f2f109b312bcdfb32e4d6be9.zip |
Update to 0.3.1.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@12738 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'sysutils/consolekit/files/ck-get-x11-display-device')
-rw-r--r-- | sysutils/consolekit/files/ck-get-x11-display-device | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sysutils/consolekit/files/ck-get-x11-display-device b/sysutils/consolekit/files/ck-get-x11-display-device new file mode 100644 index 000000000..6fc508360 --- /dev/null +++ b/sysutils/consolekit/files/ck-get-x11-display-device @@ -0,0 +1,35 @@ +#!/bin/sh + +FSTAT="/usr/bin/fstat" +GREP="/usr/bin/grep" +AWK="/usr/bin/awk" +SED="/usr/bin/sed" +CAT="/bin/cat" +HEAD="/usr/bin/head" + +dispnum=0 +if [ x"$1" = x"--display" ]; then + if [ $# != 2 ]; then + echo "usage: $0 [--display DISPLAY]" + exit 1 + fi + DISPLAY=$2 +fi +if [ ! -z "${DISPLAY}" ]; then + dispnum=$(echo ${DISPLAY} | ${SED} -E -e 's|:([0-9]+).*|\1|') +fi + +if [ ! -f "/tmp/.X${dispnum}-lock" ]; then + echo "ERROR: Failed to find X lock file for display ${dispnum}" + exit 1 +fi +pid=$(${CAT} "/tmp/.X${dispnum}-lock") + +device=$(${FSTAT} -p ${pid} | ${GREP} ttyv | ${HEAD} -1 | ${AWK} '{print $8}') + +if [ -z "${device}" ]; then + echo "ERROR: Failed to find TTY device for X server on display ${dispnum}" + exit 1 +fi + +echo "/dev/${device}" |