5
5
PATH="$PATH:/usr/bin/X11"
6
6
POWERSTATE="/var/lib/acpi-support/powerstate"
8
# getXuser: get the user for the specified X display, or if none is
9
# specified, then the user for whatever X display we find.
10
# input: $displaynum: the X display to query
11
# output: $XAUTHORITY: the path to the xauth data used for connecting to the
13
# $user: the username of the user who owns the display.
9
user=$(who | awk "/:$displaynum)/ { print \$1; exit }")
15
local display userhome uid
16
if [ -z "$displaynum" ]; then
19
display=":$displaynum"
21
uid=$(ck-list-sessions | awk 'BEGIN { unix_user = ""; } /^Session/ { unix_user = ""; } /unix-user =/ { gsub(/'\''/,"",$3); unix_user = $3; } /x11-display = '\'$display\''/ { print unix_user; exit (0); }')
11
if [ x"$user" = x"" ]; then
12
user=$(who | awk "/:$displaynum/ { print \$1; exit }")
14
if [ x"$user" != x"" ]; then
15
userhome=`getent passwd $user | cut -d: -f6`
23
if [ -n "$uid" ]; then
24
user=$(getent passwd $uid | cut -d: -f1)
25
userhome=$(getent passwd $user | cut -d: -f6)
16
26
export XAUTHORITY=$userhome/.Xauthority
18
29
export XAUTHORITY=""
33
# getXconsole: get the information for the active X console, if any.
34
# calls getXuser to get information related to the logged-in user.
36
# output: $XAUTHORITY: the path to the xauth data used for connecting to the
38
# $DISPLAY: the X display
39
# $user: the username of the user who owns the display.
24
displaynum=`ps t tty$console | sed -n -re 's,.*/X .*:([0-9]+).*,\1,p'`
25
if [ x"$displaynum" != x"" ]; then
43
displaynum=$(ck-list-sessions | awk 'BEGIN { active = 0; } /^Session/ { active = 0; } /active = TRUE/ { active = 1; } active && /x11-display = '\':.+\''/ { gsub(/'\':*'/,"",$3); print $3; exit (0); }')
45
if [ -n "$displaynum" ]; then
26
46
export DISPLAY=":$displaynum"