Phil Endecott wrote:
> Bart Samwel wrote:
>> getXuser() {
>> w -hs | while read -r THIS_USER THIS_TTY THIS_DISPLAY
>> DUMMY_REMAINDER; do
>> if [ "$THIS_DISPLAY" = "$displaynum" ] ; then
>> user=$THIS_USER
>> break
>> fi
>> done
>> if [ x"$user" = x"" ]; then
>> startx=`pgrep -n startx`
>> if [ x"$startx" != x"" ]; then
>> user=`ps -o user --no-headers $startx`
>> fi
>> fi
>> if [ x"$user" != x"" ]; then
>> userhome=`getent passwd $user | cut -d: -f6`
>> export XAUTHORITY=$userhome/.Xauthority
>> else
>> export XAUTHORITY=""
>> fi
>> export XUSER=$user
>> }
>
> No this doesn't work for me. You're looking for :0 in the FROM column,
> right? I have it in the TTY column:
>
> $ w -hs
> phil tty1 - 17:19 -bash
> root tty2 - 15:31 -bash
> phil pts/0 egypt.chezphil.o 0.00s sshd: phil [priv]
> phil pts/2 egypt.chezphil.o 1:54 nano
> libskyline/src/compute_skyline.cc
> phil :0 - ?xdm? -:0
>
> Very peculiar. I'm not really sure what to suggest; I think that
> understanding what w, who, finger etc. are really trying to tell us WRT
> X sessions would be a good start. I doubt there's anything useful in
> the man pages....
Darn. I see that you use xdm, that might explain the difference. No clue
WHY this makes things different, but apparently it does. It's
interesting to note that your FROM column was dipslayed in the Office
column by finger, and I was getting my display from there as well.
Anyway, I can simply check both columns:
getXuser() {
w -hs | while read -r THIS_USER THIS_TTY THIS_FROM DUMMY_REMAINDER; do
if [ "$THIS_TTY" = "$displaynum" -o "$THIS_FROM" =
"$displaynum" ] ; then
user=$THIS_USER
break
fi
done
if [ x"$user" = x"" ]; then
startx=`pgrep -n startx`
if [ x"$startx" != x"" ]; then
user=`ps -o user --no-headers $startx`
fi
fi
if [ x"$user" != x"" ]; then
userhome=`getent passwd $user | cut -d: -f6`
export XAUTHORITY=$userhome/.Xauthority
else
export XAUTHORITY=""
fi
export XUSER=$user
}
Does this version work for you?
Cheers,
Bart
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]